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: Single App needs two appenders with two sets of rights question
Date Mon, 13 Jun 2005 19:25:04 GMT
Appenders support Threshold levels, that is the minimum level that an
event must have to be logged. This is equivalent to a LevelRangeFilter
but less typing!

<appender name="email" type="log4net.Appender.SmtpAppender,log4net">
	<threshold value="ERROR" />

	...
</appender>



Nicko

> -----Original Message-----
> From: Ron Grabowski [mailto:rongrabowski@yahoo.com] 
> Sent: 13 June 2005 18:57
> To: Log4NET User
> Subject: Re: Single App needs two appenders with two sets of 
> rights question
> 
> You could put a filter on the email appender:
> 
> http://logging.apache.org/log4net/release/manual/configuration
> .html#filters
> 
> <appender name="email" type="log4net.Appender.SmtpAppender">
>  <filter type="log4net.Filter.LevelRangeFilter">
>   <levelMin value="ERROR" />
>   <levelMax value="FATAL" />
>  </filter>
>  ...
> </appender>
> 
> --- "McAninch, Robin" <RMcAninc@russellmellon.com> wrote:
> 
> > Hi
> > 
> > I have a requirement to write to a log file for all normal logging 
> > actions using the rolling file appender attached to the 
> root or some 
> > other logger level.  I additionally need to send an email 
> to a given 
> > address if a fatal or Error message occurs.  Both appenders work by 
> > themselves or attached to a logger at the same level but 
> that is the 
> > problem.  I need global coverage for both but only want to write 
> > emails for the serious errors.  How can I configure my file 
> to allow 
> > me debug level for writing to the logfile and fatal level 
> sending of 
> > emails while covering the entire app.  Right now I either 
> accept the 
> > same level for both or the more restrictive level 
> supercedes the more 
> > general one.
> > 
> > <root>
> > 	<level value="Debug" />
> > 		<appender-ref ref="rollingFile" />
> > 		<appender-ref ref="email" />
> > 	</root>
> > 	
> > 	<!-- Define some output appenders -->
> > 	<appender name="rollingFile"
> > type="log4net.Appender.RollingFileAppender,log4net">
> > 		<param name="File" value="MyFile.Business.Test.log" />
> > 		<param name="AppendToFile" value="true" />
> > 		<param name="RollingStyle" value="Date" />
> > 		<param name="DatePattern" value="yyyy.MM.dd" />
> > 		<param name="StaticLogFileName" value="true" />
> > 		<layout type="log4net.Layout.PatternLayout,log4net">
> > 			<param name="ConversionPattern" 
> value="%d [%t] %-5p %c [%x] 
> > &lt;%X{auth}&gt; - %m%n" />
> > 		</layout>
> > 	</appender>
> > 	
> > 	<!-- Define some output appenders -->
> > 	<appender name="email" 
> type="log4net.Appender.SmtpAppender,log4net">
> > 		<param name="From" value="Alert" />
> > 		<!--
> > 		<param name="Username" value="[optional user name]" />
> > 		<param name="Password" value="[optional password]" />
> > 		-->
> > 		<param name="To" value="user@mysite.com"/>
> > 		<param name="Subject" value="Fatal Error in program."/>
> > 		<layout type="log4net.Layout.PatternLayout,log4net">
> > 			<param name="ConversionPattern" 
> value="%d [%t] %-5p %c [%x] 
> > &lt;%X{auth}&gt; - %m%n" />
> > 		</layout>
> > 		
> > 	</appender>
> > 
> > 
> > Thanks,
> > 
> > Robin
> > 
> 
> 

Mime
View raw message