[play 2.4.1] Logback not writing to file

1,646 views
Skip to first unread message

toniObject

unread,
Mar 31, 2016, 8:30:33 AM3/31/16
to play-framework
Hi all,

I'm trying to configure logback to write to a file. This is my logback.xml so far (it's the default configuration from the play docs).

<!--
  ~ Copyright (C) 2009-2015 Typesafe Inc. <http://www.typesafe.com>
  -->
<!-- The default logback configuration that Play uses if no other configuration is provided -->
<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%n%xException</pattern>
        </encoder>
    </appender>
    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
        <encoder>
            <pattern>%coloredLevel %logger{15} - %message%n%xException{10}</pattern>
        </encoder>
    </appender>
    <appender name="ASYNCFILE" class="ch.qos.logback.classic.AsyncAppender">
        <appender-ref ref="FILE" />
    </appender>
    <appender name="ASYNCSTDOUT" class="ch.qos.logback.classic.AsyncAppender">
        <appender-ref ref="STDOUT" />
    </appender>
    <logger name="play" level="INFO" />
    <logger name="application" level="DEBUG" />
    <!-- Off these ones as they are annoying, and anyway we manage configuration ourself -->
    <logger name="com.avaje.ebean.config.PropertyMapLoader" level="OFF" />
    <logger name="com.avaje.ebeaninternal.server.core.XmlConfigLoader" level="OFF" />
    <logger name="com.avaje.ebeaninternal.server.lib.BackgroundThread" level="OFF" />
    <logger name="com.gargoylesoftware.htmlunit.javascript" level="OFF" />
    <root level="WARN">
        <appender-ref ref="ASYNCFILE" />
        <appender-ref ref="ASYNCSTDOUT" />
    </root>
</configuration>

I removed all log entries in the main application.conf and have seperated application.conf files. I start the application by this command line "sbt 'run -Dconfig.resource=application.local.dev.conf'". I think the logback.xml in conf folder isn't recognized, but why? I also tried this command line "-Dlogger.resource=logback.xml" with the same result. Anybody an idea? 

Regards, 
Toni

Will Sargent

unread,
Mar 31, 2016, 7:11:58 PM3/31/16
to play-fr...@googlegroups.com
Turn on <root level="TRACE"> in your logback.xml file before you do anything else -- there just might not be anything wrong that needed to be logged.

As far as setting up stuff on the command line -- the settings that you're looking at are for deployment / production, and "sbt run" is the development mode.  If you want to change any system properties there, you need to do:

fork in run := true

javaOptions in run ++= Seq("/my/logback-dev.xml") 

etc.  

Will.


--
You received this message because you are subscribed to the Google Groups "play-framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to play-framewor...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/play-framework/9c696b21-78c5-4ccf-a429-c4a3377858e0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

toniObject

unread,
Apr 4, 2016, 3:19:28 AM4/4/16
to play-framework
Hi Will,

Thank you for the suggestions and sorry for the late response. I changed the logback.xml like this:
    <root level="TRACE"/>
</configuration>

This still doesn't work for me. Any other ideas?

Regards, 
Toni

Will Sargent

unread,
Apr 5, 2016, 12:07:53 AM4/5/16
to play-framework
Did you try changing the build.sbt settings I described?

Elton Marku

unread,
Apr 5, 2016, 3:02:41 AM4/5/16
to play-fr...@googlegroups.com
Hi Will,

thank your for tip, I realized that the logging is ok in production. The changes in .sbt made it possible to log also in dev mode into the file. 

Thanks!

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/t6H0bcD7rSQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to play-framewor...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/play-framework/78359fe2-7e55-40c0-82e2-80a6b053278c%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages