1

I'm trying to configure a standalone Scalatra app to log to a file. I'm following the official manual and added this to build.sbt:

"ch.qos.logback" % "logback-classic" % "1.2.3" % "runtime"

I also added /src/main/resources/logback.xml with the following config:

<configuration debug="false">
<appender name="file" class="ch.qos.logback.core.fileappender">
    <file>/var/log/webapp.log</file>
    <encoder>
        <pattern>%d{hh:mm:ss.sss} [%thread] %-5level %logger{36} - %msg%n</pattern>
    </encoder>
</appender>

<logger name="org.eclipse.jetty.server" level="warn"/>
<logger name="org.eclipse.jetty.util.log" level="warn"/>

<root level="info">
    <appender-ref ref="file" />
</root>
</configuration>

But when I assemble a jar and run it, all stdout is full of DEBUG level logs from jetty, and no /var/log/webapp.log file is present.

I also had this error message while building:

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.

What am I missing?

Vladimir Mikhaylovskiy
  • 1,955
  • 4
  • 19
  • 28

1 Answers1

0

This is mainly because the logback-classic library is not available on classpath. Check if the resolvers are not overridden to ignore MavenCentral.

nashter
  • 1,181
  • 1
  • 15
  • 33