I think I might be running into the problem defined by this post:
https://issues.apache.org/jira/browse/LOG4NET-274
Here's the setup. We've created a client framework which exposes some event
creation methods. We expect those methods to get called in order to generate
events. Then the application calls log4net to log the event. I was just
debugging some issue where events weren't being logged. We couldn't figure out
what was going on. Everything seemed to be setup correctly yet no events were
flowing. Almost as if they were being filtered out. I turned on debug and
noticed a difference between when the events weren't being logged and when they
were. When the events did get logged I noticed the following entry in the
debug output:
log4net: Creating repository for assembly [...]
This line was missing in the debug output when the events weren't getting
logged.
The application is a console application. The first thing it does in Main() is:
XmlConfigurator.Configure();
The application explicitly links with our client framework. Our client
framework has the following helper class:
public static class CustomLevels
{
public static readonly Level Compliance =
LogManager.GetRepository().LevelMap["COMPLIANCE"];
}
public static class Logging
{
public static void Compliance(this ILog logger, object o)
{
logger.Logger.Log(null, CustomLevels.Compliance, o, null);
}
}
So I was wondering if maybe the Compliance static readonly field was getting
initialized before XmlConfigurator.Configure() was called and thus the
Compliance Level was not correct. This would cause the behavior we experience
where nothing was getting logged because we have a filter on our appender to
filter out everything but compliance level.
Our application config file has the compliance level defined as follows:
<log4net>
<level>
<name value="COMPLIANCE"/>
<value value="140000"/>
</level>
...
</log4net>
Thanks,
Nick