How to make 404 pages not write error log?

In our philosophy, the error log is always caused by a programmer error.

In playback mode 1.2.x, prod mode, any access to a page that does not exist causes an error log:

ERROR (play) ~ 
MyController.myAction action not found
Action not found
Action MyController.myAction could not be found. Error raised is No method public static void myAction() was found in class controllers.MyController
play.exceptions.ActionNotFoundException: Action MyController.myAction not found
    at play.mvc.ActionInvoker.getActionMethod(ActionInvoker.java:604)
    at play.mvc.ActionInvoker.resolve(ActionInvoker.java:85)
    at Invocation.HTTP Request(Play!)
Caused by: java.lang.Exception: No method public static void myAction() was found in class controllers.MyController

How to configure Play so as not to display an error log in these cases? Perhaps the log level is WARNno more?

+5
source share
2 answers

The logging code is in ActionInvoker.java (play 1.2.5RC4):

catch (ActionNotFoundException e) {
            Logger.error(e, "%s action not found", e.getAction());
            throw new NotFound(String.format("%s action not found", e.getAction()));
        }

So, there seems to be no way to adjust the ActionNotFoundException logging level. I agree that this should not be at the “error” level. I would recommend opening a ticket at https://play.lighthouseapp.com/dashboard .

+6

, ExpressionFilter Apache log4j Extras :

dependencies.yml

- log4j -> apache-log4j-extras 1.2.17:
    transitive: false

< > .conf:

log4j.appender.<appender>.filter.1=org.apache.log4j.filter.ExpressionFilter
log4j.appender.<appender>.filter.1.expression=EXCEPTION ~= play.exceptions.ActionNotFoundException
log4j.appender.<appender>.filter.1.acceptOnMatch=false

, 4jj appender acceptOnMatch , ActionNotFound.

0

All Articles