[logback-user] root level appender config not working

Thomas Grainger tagrain at gmail.com
Mon Mar 27 15:00:15 CEST 2017


yeah I see that now. Upsetting that it compiled and ran though. Could do
with an XSD.

Thomas Grainger

On 27 March 2017 at 13:58, Andrew Feller <afeller at bandwidth.com> wrote:

> I'm not sure as there is no DTD for logback.xml due to the complexity of
> it.  It probably reconfigures the root logger for each element it sees, but
> I'm really not going to dig through the code to confirm that.
>
> If you look at Chp 3 Configuration Syntax
> <https://logback.qos.ch/manual/configuration.html#syntax>, you'll notice
> a diagram explaining the high-level elements and their cardinality within
> the configuration file with only a single root element.
>
>
> Chp 7 Filters has an entry on ThresholdFilter filter
> <https://logback.qos.ch/manual/filters.html#thresholdFilter>, which is
> exactly what you need.
>
>
> On Mon, Mar 27, 2017 at 8:40 AM, Thomas Grainger <tagrain at gmail.com>
> wrote:
>
>> ah ok, why did my application boot with the first configuration? Is that
>> a logback bug?
>>
>> Thomas Grainger
>>
>> On 27 March 2017 at 13:39, Andrew Feller <afeller at bandwidth.com> wrote:
>>
>>> You can only have a single root element.  If you want to filter log
>>> events by severity / priority by appender, then you should use the
>>> ThresholdFilter filter per appender.
>>>
>>> On Mon, Mar 27, 2017 at 4:42 AM, Thomas Grainger <tagrain at gmail.com>
>>> wrote:
>>>
>>>> I have a config file:
>>>>
>>>> <configuration>
>>>>
>>>>   <conversionRule conversionWord="coloredLevel"
>>>> converterClass="play.api.Logger$ColoredLevel" />
>>>>   <contextListener class="com.procensus.backend.l
>>>> ogging.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.AwsLogs
>>>> Appender">
>>>>       <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.log
>>>> back.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.l
>>>> ogging.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.AwsLogs
>>>> Appender">
>>>>       <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.log
>>>> back.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
>>>>
>>>> _______________________________________________
>>>> logback-user mailing list
>>>> logback-user at qos.ch
>>>> http://mailman.qos.ch/mailman/listinfo/logback-user
>>>>
>>>
>>>
>>>
>>> --
>>>
>>> [image: email-signature-logo.jpg]
>>>
>>> *Andy Feller*
>>>
>>> Sr. DevOps Engineer
>>> 900 Main Campus Drive, Suite 500
>>>
>>> Raleigh, NC 27606
>>>
>>> Bandwidth <http://www.bandwidth.com/>
>>> <http://www.bandwidth.com/>e afeller at bandwidth.com
>>>
>>> _______________________________________________
>>> logback-user mailing list
>>> logback-user at qos.ch
>>> http://mailman.qos.ch/mailman/listinfo/logback-user
>>>
>>
>>
>> _______________________________________________
>> logback-user mailing list
>> logback-user at qos.ch
>> http://mailman.qos.ch/mailman/listinfo/logback-user
>>
>
>
>
> --
>
> [image: email-signature-logo.jpg]
>
> *Andy Feller*
>
> Sr. DevOps Engineer
> 900 Main Campus Drive, Suite 500
>
> Raleigh, NC 27606
>
> Bandwidth <http://www.bandwidth.com/>
> <http://www.bandwidth.com/>e afeller at bandwidth.com
>
> _______________________________________________
> logback-user mailing list
> logback-user at qos.ch
> http://mailman.qos.ch/mailman/listinfo/logback-user
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.qos.ch/pipermail/logback-user/attachments/20170327/b55ac0d3/attachment-0001.html>


More information about the logback-user mailing list