Sorry for the abiguity. I want the messages to go to a file.
To reiterate, I want the log to contain all info messages and above.
When an error occurs, I want additional information, all the way down to
the debug level. So if an error occurs, I will have the last 500 log
messages that will tell me what led up to that event.
I really appreciate any help you can provide.
Here is what I have so far:
<?xml version="1.0" encoding="utf-8" ?>
<log4net>
<!-- Define our output appender(s) -->
<appender name="RollingFiles"
type="log4net.Appender.RollingFileAppender">
<param name="File" value="Log.txt" />
<param name="AppendToFile" value="true" />
<param name="MaxSizeRollBackups" value="20" />
<param name="MaximumFileSize" value="10MB" />
<param name="RollingStyle" value="Size" />
<param name="StaticLogFileName" value="true" />
<layout type="log4net.Layout.PatternLayout">
<param name="Header" value="***** Log Started *****\r\n"/>
<param name="Footer" value="***** Log Ended *****\r\n"/>
<param name="ConversionPattern" value="%d [%t] %-5p %c [%x]
- %m%n" />
</layout>
</appender>
<appender name="BFA"
type="log4net.Appender.BufferingForwardingAppender" >
<bufferSize value="512" />
<lossy value="true" />
<evaluator type="log4net.Core.LevelEvaluator">
<threshold value="ERROR"/>
</evaluator>
<appender-ref ref="RollingFiles" />
</appender>
<!-- Setup the root category, add the appenders and set the default
level -->
<root>
<level value="INFO" />
<appender-ref ref="RollingFiles" />
</root>
<!--
Send all messages to the Buffering Forwarding
Appender so that it can
log the debug messages when it encounters an
ERROR level message.
-->
<logger name="root">
<level value="DEBUG" />
<appender-ref ref="BFA" />
</logger>
</log4net>
-----Original Message-----
From: Nicko Cadell [mailto:[EMAIL PROTECTED]
Sent: Thursday, August 25, 2005 10:04 AM
To: Log4NET User
Subject: RE: Change logging level with a trigger
Jason,
> We only want to log info messages and above, but if a warning or above
> is encountered, we want it to output the last x number of messages.
When you say last x messages, do you mean of only Info and above?
If so then just set the logger level to Info.
<root>
<level value="Info" />
<appender-ref ...>
</root>
> The buffered file appender looks like it almost does this, but not
> quite.
Where do you want the log messages to go? file, email etc...
> We've also been able to log all messages, but send an email on error
> messages with the buffer.
If you want to trigger sending the buffer on Warn events then you need
to specify a threshold value on the Evaluator of the
BufferingForwardingAppender.
<evaluator type="log4net.Core.LevelEvaluator">
<threshold value="Warn" />
</evaluator>
> Does someone have an example config file that I could see?
>
> If you need more clarification, or want to see where I got stuck,
> please let me know.
Why don't you post the log4net configuration you currently have.
Cheers,
Nicko
>
> Thanks,
> Jason
>