logging-log4net-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ron Grabowski <rongrabow...@yahoo.com>
Subject Re: configuration file question
Date Wed, 25 Jul 2007 04:40:29 GMT
One solution would be to configure the logger to send all of its messages:

<logger name="Logger1">
 <level value="ALL" />
 <appender-ref ref="ForwardingAppender"  />
</logger>

to a ForwardingAppender which in turns routes the message to two other appenders:

<appender name="ForwardingAppender" type="log4net.Appender.ForwardingAppender">
 <appender-ref ref="DebugFileAppender" />
 <appender-ref ref="FatalFileAppende" />
</appender>

which have the appropriate settings:

<appender name="DebugFileAppender" type="log4net.Appender.FileAppender">
 <file value="Debug.txt" />
 <layout type="log4net.Layout.SimpleLayout" />
</appender>

<appender name="FatalFileAppender" type="log4net.Appender.FileAppender">
 <file value="Fatal.txt" />
 <threshold value="FATAL" />
 <layout type="log4net.Layout.SimpleLayout" />
</appender>

----- Original Message ----
From: Dan Blanchard <sattvikvibes@gmail.com>
To: log4net-user@logging.apache.org
Sent: Thursday, July 19, 2007 1:08:13 PM
Subject: configuration file question 

Hi,

Read through the docs and couldn't find the answer...

1. Let's say I have 2 appenders, and I want to have the same logger send 
different levels to different appenders, but it does not appear to work, 
nothing is going through.  Is this possible?  If not, is there another 
way to accomplish this?  I was considering putting it as a filter on the 
appender, but I would like other loggers at different levels go to that 
appender, so that won't work.

        <logger name="Logger1">
            <level value="All" />
            <appender-ref ref="Appender1"  />
        </logger>

        <logger name="Logger1">
            <level value="ERROR" />
            <appender-ref ref="Appender2"  />
        </logger>

Thanks,

Dan





Mime
View raw message