logging-log4net-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jesper Lund Stocholm" <jesper.stoch...@ciber.dk>
Subject RE: Piping log messages to different appenders via LEVEL
Date Fri, 17 Dec 2010 11:37:55 GMT
Hi Ross,


Thank you very much - it now works like a charm. Looking at the SDK
(again), I now realized that the object model mirrors the configuration
template (or vice versa). Moving the <Threshold>-element "up" solved the
problem. I dropped the <evaluator>-element from my RollingFileAppender
at the same time.


Thanks for your input :o)



Med venlig hilsen / Best regards


Jesper Lund Stocholm


CIBER Danmark A/S

Mobil: +45 3094 5570

Email: jesper.stocholm@ciber.dk <mailto:jesper.stocholm@ciber.dk> 


materials in this electronic transmission (including attachments) may be
subject to attorney-client or work product privilege, may be private and
confidential and are the property of the sender. The information
contained is intended only for the named addressee(s) and should not be
considered evidence of intent to be bound to any agreement. The taking
of any action in reliance on the contents is strictly prohibited. If you
are not the intended recipient of this message, please immediately
notify the sender and promptly delete this message.


From: Ross Hinkley [mailto:rosshinkley@gmail.com] 
Sent: Thursday, December 16, 2010 4:38 PM
To: Log4NET User
Subject: Re: Piping log messages to different appenders via LEVEL


You should be able to use the Threshold tag under the appender to
specify what level you'd like to start logging.  The threshold is

The log4net SDK outlines how it works:

I've modified your configuration below; I think it's correct.  Let me
know if you have trouble with it.


On Thu, Dec 16, 2010 at 8:12 AM, Jesper Lund Stocholm
<jesper.stocholm@ciber.dk> wrote:

I would like to send log messages to one of two appenders depending on
the level of the message. Specifically, I'd like this:


Everything: send to Console

Error and above: send to file


So I have configured these two appenders:


<appender name="Console" type="log4net.Appender.ConsoleAppender"> 
         <threshold value="ALL" />

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

	      <conversionPattern value="%date %-4timestamp [%thread]
%-5level %logger %ndc - %message%newline" />




	<appender name="RollingFileAppender"
	  <threshold value="ERROR" />

	  <file value="C:\Windows\Temp\servicelog_01.txt" />

	  <appendToFile value="true" />

	  <lockingModel type="log4net.Appender.FileAppender+MinimalLock"

	  <rollingStyle value="Size" />

	  <maxSizeRollBackups value="10" />

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

	    <conversionPattern value="%date %-4timestamp [%thread]
%-5level %logger %ndc - %message%newline" />


	  <evaluator type="log4net.Core.LevelEvaluator">

	    <threshold value="ERROR"/>




	I would have thought that adding the <evaluator>-element to the
RollingFileAppender would filter the messages only saving the messages
with level "ERROR and above", but everything still gets send to both


	Can you tell me what I am missing here?






	Med venlig hilsen / Best regards


	Jesper Lund Stocholm

	Seniorarkitekt / Senior architect



View raw message