logging-log4net-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "McAninch, Robin" <RMcAn...@russellmellon.com>
Subject Single App needs two appenders with two sets of rights question
Date Mon, 13 Jun 2005 17:32:15 GMT
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