Configuring Logging in Play 2.2.x
Well, actually it is pretty straightforward, just follow this Play 2.2.x documentation. But there is a caveat that costs me several hours to resolve.
[caption id=”attachment_1090” align=”aligncenter” width=”300”] Play Framework[/caption]
Based on Play 2.2.x documentation , we should use `-Dlogger.resource` after the command `start` inside Play console, i.e
[OS-console] $ play [info] Loading project definition from …. [info] … ….. //initialization message from Play [play-console] $ start -Dlogger.resource=my-logging-configuration.xml
But what if we want to invoke it outside Play console? Does this command below work properly?
play start -Dlogger.resource=my-logging-configuration.xml
Well the answers is NO!
So, I add some code on my controller to print the logging configuration file (which is logback configuration file) and Play does not consider the VM arguments (i.e. -Dlogger.resource) using above command. Logback uses the default Play’s logger.xml in `$PROJECT_HOME/play-2.2.x/repository/local/com.typesafe.play/play_2.10/2.2.x/jars/play_2.10.jar!/logger.xml`
So, to resolve this, we should invoke the “play start” command as below:
play -Dlogger.resource=my-logging-config.xml -Dother.vmarg=val start
That’s all for this month! See you (hopefully earlier than) next month!