log4net - Different appenders per namespace -
I am trying to set up a general logging library which is based on the ILog
example Determine what is the best example of the current stack and how to use
I have this kind of configuration set:
& lt; Log4net & gt; & Lt ;! - attachments skipped - & gt; & Lt; Root & gt; & Lt; / Root & gt; & Lt; Name of the logger = "MyAssembly.MyNamespace" & gt; & Lt; Level value = "WARN" /> & Lt ;! - Appendix list - & gt; & Lt; / Logger & gt; & Lt; / Log4net & gt;
And I have a class like this:
namespace myAssembly.MyNamespace.SubNamespace {public class MyClass {...}}
When I get an example of img
, type me ( var log = LogManager.GetLogger (typeof) MyClass)) namespace;
) and I have to find out that no logger is configured, so it is named in the namespace tree ( MyAssembly.MyNamespace
) and then see if it is configured at that point.
The problem is that for the ILog
the
log4net
Based on their names, Therefore, logger with name MyAssembly.MyNamespace.SubNamespace
is the name of the logger named with name MyAssembly.MyNamespace
.
If no level (warning etc.) is specified for a logger, then the system logger enters the hierarchy until it gets a logger with a configured level - and that The effective level for the logger becomes level.
In your case, no level is assigned to the child's logger, so it attains its basic level. If you specify
& lt; Name of the logger = "MyAssembly.MyNamespace.SubNamespace" & gt; & Lt; Level value = "DEBUG" /> & Lt ;! - or whatever - & gt; & Lt ;! - No need to specify the attendants, the parents will use - & gt; & Lt; / Logger & gt;
Then you will get debug output from the child's logger (sent to the appenders configured for the guardian).
Comments
Post a Comment