logging-log4net-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rob Prouse <Rob.Pro...@Ivara.com>
Subject RE: root level logger using other logger level
Date Fri, 30 May 2008 11:18:26 GMT
Don,

The root logger does not inherit the other logger levels, all of your other logger levels
below root inherit the appenders from the root logger. So your EnterpriseApplicationIntegration
will inherit the root appender and log to trafficControl.log.

You have two choices here,


1.      Add a level filter to your TrafficControl appender to only log ERROR and FATAL.

2.      On your other loggers, set the attribute additivity="false" so they do not inherit
the TrafficControl appender. The only problem with this is that Error and Fatal messages from
your other logs will not go to TrafficControl.

Does this make sense or do you need some examples?

Rob Prouse

From: Don Taylor [mailto:Don.Taylor@Tideworks.com]
Sent: May-29-08 5:58 PM
To: log4net-user@logging.apache.org
Subject: root level logger using other logger level


We have multiple loggers set up for various services that make up our system.  I think I have
the service configured to log ERRORs (and FATAL) to one file for all code, then qualified
a couple separate thread based services to log debug type information to other files.  Instead
I see DigitalBridgeTrafficControl INFO message in trafficControl.log, where I thought should
ONLY see ERROR and FATAL.

Does a root logger inherit other logger levels, or did I just screw the configuration up?

The log4net.config file:

<?xml version="1.0" encoding="utf-16"?>

<log4net>

  <appender name="Console" type="log4net.Appender.ConsoleAppender">

    <layout type="log4net.Layout.PatternLayout">

      <conversionPattern value="%date{ABSOLUTE} %thread %logger %5level [%message] %newline%exception"
/>

    </layout>

  </appender>

  <appender name="EventLogger" type="log4net.Appender.EventLogAppender">

    <layout type="log4net.Layout.PatternLayout">

      <conversionPattern value="%date{ABSOLUTE} %thread %logger %5level [%message] %newline%exception"
/>

    </layout>

    <logName value="Traffic Control" />

  </appender>

  <appender name="TrafficControl" type="log4net.Appender.RollingFileAppender">

    <layout type="log4net.Layout.PatternLayout">

      <conversionPattern value="%date{ABSOLUTE} %thread %logger %5level [%message] %newline%exception"
/>

    </layout>

    <file value="trafficControl.log" />

    <appendToFile value="true" />

    <maximumFileSize value="10MB" />

    <maxSizeRollBackups value="10" />

  </appender>

  <appender name="DigitalBridgeTrafficControl" type="log4net.Appender.RollingFileAppender">

    <layout type="log4net.Layout.PatternLayout">

      <conversionPattern value="%level: %date{ISO8601} %logger [%message] %exception%newline"
/>

    </layout>

    <file value="digitalBridgeTrafficControl.log" />

    <appendToFile value="true" />

    <datePattern value="yyyyMMdd" />

    <maxSizeRollBackups value="28" />

  </appender>

  <appender name="MessageLifetimeUdpAppender" type="log4net.Appender.UdpAppender">

    <remoteAddress value="localhost" />

    <remotePort value="8080" />

    <layout type="log4net.Layout.XmlLayout, log4net" />

    <encoding value="Unicode" />

  </appender>

  <appender name="MessageLifetimeRemotingAppender" type="log4net.Appender.RemotingAppender">

    <sink value="tcp://localhost:8081/LoggingSink" />

    <lossy value="false" />

    <bufferSize value="95" />

    <layout type="log4net.Layout.XmlLayout, log4net" />

  </appender>

  <appender name="ICUFileRolloverLogger" type="log4net.Appender.RollingFileAppender">

    <file value="ICU Logs\ICU.log" />

    <appendToFile value="true" />

    <maximumFileSize value="50MB" />

    <maxSizeRollBackups value="100" />

    <layout type="log4net.Layout.PatternLayout">

      <conversionPattern value="%date{ISO8601},%message%newline" />

    </layout>

  </appender>

  <root>

    <level value="ERROR" />

    <appender-ref ref="TrafficControl" />

  </root>

  <logger name="EnterpriseApplicationIntegration">

    <level value="ALL" />

    <appender-ref ref="DigitalBridgeTrafficControl" />

  </logger>

  <logger name="Tideworks.TC.ICUUtilities">

    <level value="INFO" />

    <appender-ref ref="ICUFileRolloverLogger" />

  </logger>

</log4net>

Thanks for any help!

Don

Mime
View raw message