logging-log4net-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nicko Cadell" <ni...@neoworks.com>
Subject RE: Double configuration and SmtpAppender configuration
Date Thu, 02 Mar 2006 17:32:14 GMT
Loggers can only have one level. If you need to have more control over
the logging performed by an appender you can set its <threshold> level.
If that is not sufficient you can attach several different filters to
the appender that determine if the event should be output, you can even
write your own filters.
http://logging.apache.org/log4net/release/manual/introduction.html#filte
rs

So my suggestion would be to set the <threshold> on the CustomAppender
like so:

<root>
  <level value="ALL" />
</root>

<logger name="Log4net.MainForm">
  <appender-ref ref="AdoNetAppender" />
  <appender-ref ref="SmtpAppender" />
  <appender-ref ref="CustomAppender" />
</logger> 

<appender name="CustomAppender" type="..">
  <threshold value="WARN" />
  ...
</appender>

Cheers,
Nicko

> -----Original Message-----
> From: Vladimir Kovalenko [mailto:gaset.kovalenko@gmail.com] 
> Sent: 02 March 2006 09:20
> To: log4net-user@logging.apache.org
> Subject: Double configuration and SmtpAppender configuration
> 
> Hi, I need some help.
> 
>  
> 
> 1) I want to configure log level for Log4net.MainForm logger 
> in the following maner:
> 
>  
> 
>     <root>
> 
>       <level value="ALL" />
> 
>     </root>
> 
>  
> 
>     <logger name="Log4net.MainForm">
> 
>       <level value="WARN" />
> 
>       <appender-ref ref="CustomAppender" />
> 
>     </logger>
> 
>     
> 
>     <logger name="Log4net.MainForm">
> 
>       <level value="ALL" />
> 
>       <appender-ref ref="AdoNetAppender" />
> 
>       <appender-ref ref="SmtpAppender" />
> 
>     </logger>
> 
>  
> 
>  
> 
> This way I want AdoNetAppender and SmtpAppender to process 
> ALL data that is passed to logger. And Only WARN and above 
> messages are handled by my CustomeAppender. Can it be 
> configured this way? 
> 
>  
> 
> Currently the second configuration is applied, but not both.
> 
>  
> 
> 2) I have SmtpAppender configured to send messages to 
> address1@mail.com. Now I want to configure Log4net.MainForm 
> logger to send messages to address2@mail.com. Can I do that 
> with configuration file?
> 
>  
> 
> Best regards,
> 
> Vladimir Kovalenko
> 
> 

Mime
View raw message