[logback-user] root level appender config not working

Thomas Grainger tagrain at gmail.com
Mon Mar 27 10:42:47 CEST 2017


I have a config file:

<configuration>

  <conversionRule conversionWord="coloredLevel"
converterClass="play.api.Logger$ColoredLevel" />
  <contextListener
class="com.procensus.backend.logging.LoggerStartupListener"/>

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

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

  <appender name="CLOUDWATCH_SYNC" class="ca.pjer.logback.AwsLogsAppender">
      <logRegion>eu-west-1</logRegion>
      <logGroupName>procensus/backend</logGroupName>
      <logStreamName>${EC2_METADATA_IP_ADDRESS}</logStreamName>
      <layout class="ch.qos.logback.contrib.json.classic.JsonLayout">
          <jsonFormatter
class="ch.qos.logback.contrib.jackson.JacksonJsonFormatter">
              <prettyPrint>false</prettyPrint>
          </jsonFormatter>
      </layout>
  </appender>

  <appender name="CLOUDWATCH" class="ch.qos.logback.classic.AsyncAppender">
      <appender-ref ref="CLOUDWATCH_SYNC"/>
  </appender>

  <appender name="SENTRY"
class="com.getsentry.raven.logback.SentryAppender">
    <dsn>https://redacted:redacted@sentry.io/redacted</dsn>
  </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" />
  <logger name="com.amazonaws.request" level="OFF" />

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

  <root level="INFO">
    <appender-ref ref="CLOUDWATCH" />
  </root>

  <root level="WARN">
    <appender-ref ref="SENTRY" />
  </root>

</configuration>

However, even though I have root level="WARN" for Sentry, I get all logging
events (eg INFO level)



When I configure a filter, my process doesn't even boot, with no error
message at all:


<configuration>

  <conversionRule conversionWord="coloredLevel"
converterClass="play.api.Logger$ColoredLevel" />
  <contextListener
class="com.procensus.backend.logging.LoggerStartupListener"/>

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

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

  <appender name="CLOUDWATCH_SYNC" class="ca.pjer.logback.AwsLogsAppender">
      <logRegion>eu-west-1</logRegion>
      <logGroupName>procensus/backend</logGroupName>
      <logStreamName>${EC2_METADATA_IP_ADDRESS}</logStreamName>
      <layout class="ch.qos.logback.contrib.json.classic.JsonLayout">
          <jsonFormatter
class="ch.qos.logback.contrib.jackson.JacksonJsonFormatter">
              <prettyPrint>false</prettyPrint>
          </jsonFormatter>
      </layout>
  </appender>

  <appender name="CLOUDWATCH" class="ch.qos.logback.classic.AsyncAppender">
      <appender-ref ref="CLOUDWATCH_SYNC"/>
  </appender>

  <appender name="SENTRY"
class="com.getsentry.raven.logback.SentryAppender">
    <dsn>https://redacted:redacted@sentry.io/redacted</dsn>
    <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
      <level>WARN</level>
    </filter>
  </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" />
  <logger name="com.amazonaws.request" level="OFF" />

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

  <root level="INFO">
    <appender-ref ref="CLOUDWATCH" />
  </root>

  <root level="WARN">
    <appender-ref ref="SENTRY" />
  </root>

</configuration>

Thomas Grainger
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.qos.ch/pipermail/logback-user/attachments/20170327/a589d1b0/attachment.html>


More information about the logback-user mailing list