[2.2.1] Logging configuration in production

258 views
Skip to first unread message

Joël Vimenet

unread,
Jan 18, 2014, 7:14:10 AM1/18/14
to play-fr...@googlegroups.com
Hello,
I have a Play 2.2.1 scala application. I have overridden the Global object onLoadConfig method to change the configuration file according the mode : application.conf in prod, application.dev.conf in dev and application.test.conf in test. This works well except for logging configuration in prod mode.

In dev mode, I set logs in DEBUG, and it works fine. I prod, I set logs in INFO, but it seems to be ignored. I configure the logs in a logger.conf file that I include in my main config file (application.conf). I use the same way in dev and it works.

Is there a configuration that takes the priority for logging in prod?

Thanks in advance for your help.

Chanan Braunstein

unread,
Jan 18, 2014, 10:48:09 AM1/18/14
to play-fr...@googlegroups.com
We use this in production:

file /conf/logger.xml: (Note: .xml not .conf)

<configuration>

<conversionRule conversionWord="coloredLevel" converterClass="play.api.Logger$ColoredLevel" />

<appender name="FILE" class="ch.qos.logback.core.FileAppender">
<file>${application.home}/logs/application.log</file>
<encoder>
<pattern>%date - [%level] - from %logger in %thread %message%xException%n</pattern>
</encoder>
</appender>

<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%coloredLevel %logger{15} - %message%xException{5}</pattern>
</encoder>
</appender>

<logger name="play" level="INFO" />
<logger name="application" level="INFO" />

<root level="ERROR">
<appender-ref ref="STDOUT" />
<appender-ref ref="FILE" />
</root>

</configuration>

Joël Vimenet

unread,
Jan 20, 2014, 2:54:40 AM1/20/14
to play-fr...@googlegroups.com
Thanks, 
I tried this, but, correct me if I am wrong, this is applied for all modes. Do you have a script to apply it only at deployment?


2014/1/18 Chanan Braunstein <cha...@gmail.com>

--
You received this message because you are subscribed to a topic in the Google Groups "play-framework" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/play-framework/I5wifwQsrp0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to play-framewor...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



--
Joël Vimenet
joel.v...@gmail.com

Chanan Braunstein

unread,
Jan 20, 2014, 10:30:45 AM1/20/14
to play-fr...@googlegroups.com
Yes, we add that during deployment that we have automated with Puppet.

Joël Vimenet

unread,
Jan 21, 2014, 3:15:08 AM1/21/14
to play-fr...@googlegroups.com
OK, I'll do something like this. I just don't understand why the logging configuration in application.conf seems to be ignored in prod, while the configuration in xml works.
Thanks.


2014/1/20 Chanan Braunstein <cha...@gmail.com>



--
Joël Vimenet
joel.v...@gmail.com

Fernando Correia

unread,
Jan 22, 2014, 5:18:50 PM1/22/14
to play-fr...@googlegroups.com
In production, Play will load the application.conf that was bundled in the jar file during dist, not the application.conf that the dist task also copies to the conf file.

To me this is rather counter-intuitive. You should use the -Dconfig.file option to load the appropriate configuration file, ignoring the one bundled in the jar.

Joël Vimenet

unread,
Jan 23, 2014, 3:09:09 AM1/23/14
to play-fr...@googlegroups.com
Ok, but it doesn't seem to be the problem here, my application.conf is the same in the jar and outside, and the logger.conf is bundled too. There are other conf files that I import in the application.conf that works correctly. The only one ignored is the logging config. Maybe it loads a default logging config that overrides the one in the *.conf files?


2014/1/22 Fernando Correia <fernando...@gmail.com>
--
You received this message because you are subscribed to a topic in the Google Groups "play-framework" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/play-framework/I5wifwQsrp0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to play-framewor...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



--
Joël Vimenet
joel.v...@gmail.com
Reply all
Reply to author
Forward
0 new messages