I think log4net does everything you specify for me.
Pluggable listeners sound like prefixes - there are a lot of them, and in fact I even cracked a sliding log file that always ended with .log (for file associations), added a cc field to the email application, and finally set up my favorite values ββfor the color console applications. If I can be so bold - my color console happiness is:
<appender name="ColoredConsoleAppender" type="log4net.Appender.ColoredConsoleAppender"> <mapping> <level value="FATAL" /> <foreColor value="Yellow, HighIntensity" /> <backColor value="Red" /> </mapping> <mapping> <level value="ERROR" /> <foreColor value="White" /> <backColor value="Purple, HighIntensity" /> </mapping> <mapping> <level value="WARN" /> <backColor value="Blue" /> <foreColor value="White" /> </mapping> <mapping> <level value="INFO" /> <backColor value="Green" /> <foreColor value="White" /> </mapping> <mapping> <level value="DEBUG" /> <foreColor value="White" /> </mapping> <layout type="log4net.Layout.PatternLayout"> <conversionPattern value="%level %logger:%line %newline %message%newline" /> </layout>
Customizable trace switches: Log4net ships with FATAL ERROR WARN INFO DEBUG in order to increase granularity. The only thing I really missed was AUDIT for those who did what they recorded.
Custom configuration: I use the log4net.config file that I load at runtime (or write a log to c: \ whining that I cannot find the configuration.)
Try ' Get log4net configuration from file Dim logConfigFile As FileInfo logConfigFile = New FileInfo(".\log4net.config") If logConfigFile.Exists Then XmlConfigurator.Configure(logConfigFile) Else CreateEmergenceLogFile(logConfigFile.FullName) End If Catch ex As Exception Console.Out.WriteLine("Could not load the log4net config file") End Try
just a great set of TraceListeners: sorry to skip this - I'll take your word for it.
The ratio of actions / areas: you mean that each file (reading class) receives its own named log, which can have separate log-level thresholds. In fact, you can segment records even in one class (this, in truth, can increase to do too much ...)
In the class file:
Private Shared _logger As log4net.ILog = _ log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType) Private Shared _loggerAttribute As log4net.ILog = _ log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName & ".Attribute") Private Shared _loggerCache As log4net.ILog = _ log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName & ".Cache")
Service Trace Viewer: in the log4net.config file:
<logger name="NipissingU.ADWrapper.EntryTools.Attribute"> <level value="INFO" /> </logger> <logger name="NipissingU.ADWrapper.EntryTools.Cache"> <level value="WARN" /> </logger>
All this is configured in app.config / web.config: well, maybe itβs good in ASP.NET, I donβt know, but when creating a rich bean client for counting applications I like the separate configuration file.
Everything here is just my own little tricks.
NTN, -Mike