Has anyone ever given any thought to alternative ILoggerRepository implementations? NLog doesn't use a hierarchy system like the log4xxx systems do. Ir uses a series of rules to determine where messages should be routed:
<!-- nlog --> <rules> <logger name="*" levels="Info" writeTo="console"/> <logger name="*SQL*" levels="Debug" writeTo="file3"/> </rules> http://www.nlog-project.org/introduction.html: " NLog uses a routing table while log4net uses a logger hierarchy with attachable appenders. " The log4net architecture allows for alternative ILoggerRepository implementations. There's nothing stopping log4net from implementing a similiar routing system. A RoutingTableRepository's config file for the same NLog config snippet may look something like this: <logger name="*"> <appender-ref="ConsoleAppender" /> <level value="DEBUG" /> </logger> <logger name="*SQL*"> <appender-ref="FileAppender" /> <level value="INFO" /> </logger> An advanced configuration would allow the logger nodes to contain filter nodes. A very oversimplified explaination of what's going on is that log4net must look through the hierarchy to determine how to process the message while NLog does a string comparison on the logger name to see if it matches the current rule. The routing table approach would process logger nodes one at a time by starting with the first one and working its way down (similiar to how filters work). I would imagine most of NLog's speed improvements (I believe Jarosław tests have shown that NLog is in the neighborhood of at least 3x faster against each system's null appender/target) over log4net are a result of this simplified comparison. For log4net to implement something similiar I think a handful of things need to be written: log4net.Repository.RoutingTable.Logger : IAppenderAttachable, ILogger log4net.Repository.RoutingTable.RoutingTable : LoggerRepositorySkeleton, IXmlRepositoryConfigurator log4net.Repository.RoutingTable.XmlRoutingTableConfigurator I've copied the Hierarchy classes and gutted out all the events, file watcher stuff, etc. to try and get basic proof-of-concept code. I don't have any working code yet. Is this something other people are interested in or use if it were available? I don't think log4net is slow and I don't have any issues with the hierarchy implementation but I can't help but think that there's a faster way of routing messages when your application has simple logging requirements: log SQL statements to a file and log everything else to the console. - Ron
