Jonas
Jonas

Reputation: 21

Monitor application.log in Play Framework

We have a standard application.log file in our Play Framework installation. To this file, all searches that are performed in the application are logged, giving the log file a new entry approx every second.

But sometimes the application will throw an error, logging it with a id in the form of @andthensomecharacters.

Now, when looking for these errors, I look through the file manually, using / to search (the application.log file gets very large). But is there a better way to monitor these errors? Can I somehow be notified if an error is thrown, or maybe have these errors also written to another file?

Any suggestions are appreciated.

The Play version is 1.2.3, and it is running in Ubuntu.

Upvotes: 2

Views: 346

Answers (1)

aaberg
aaberg

Reputation: 2273

You can annotate a method in your controller with @Catch annotation. This will cause the method to be run every time an error happens in the controller. In this method, you can save the error to a database or file.

If you want to make a common catch method for your entire application, you can implement the catch method in its own controller, and use the @With annotation to add the functionality to your other controllers.

Upvotes: 3

Related Questions