Now that I’ve figured out what I want a logging framework to do I’ve taken a look at some interesting existing frameworks. log4net is a .net logging framework based on a java framework – log4j. It’s hosted on the apache website which gives it extra credibility in my view. Looking at the feature set it looks like it covers pretty much what I need.
As far as sending emails go there’s a convenient way to get emails out when there’s a problem with a sample config in the examples.
<appender name="SmtpAppender" type="log4net.Appender.SmtpAppender">
<to value="to@domain.com" />
<from value="from@domain.com" />
<subject value="test logging message" />
<smtpHost value="SMTPServer.domain.com" />
<bufferSize value="512" />
<lossy value="true" />
<evaluator type="log4net.Core.LevelEvaluator">
<threshold value="WARN"/>
</evaluator>
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%newline%date [%thread] %-5level %logger [%property{NDC}] - %message%newline%newline%newline" />
</layout>
</appender>
What that does is send an email when a warning comes along and also sends upto the previous 512 messages (of any kind) as context. That wasn’t exactly what I was thinking of but it’s certainly good enough for the emails.

