1

I have an issue with log4net that I can't seem to find the answer to. I have set up log4net to be configured programmatically (see here). The C# / .NET application that is supposed to make use of log4net is an interface server that provides plugins for transferring data from one system (ERP, CRM, ...) to another. For each transfer you can configure a sending plugin and a receiving plugin, which build up a so called "order". Every order reads a specific datatype from the source table (e.g. ADDRESS or PROJECT) and contains field mappings to map source fields to target fields.

Orders use independent log4net logger instances - distinguished by instance name - for logging and for each order a distinct log level can be set. All logger instances are using the same ADONetAppender and are created as a private member object for each class. Also, the ADONetAppender gets created on startup and referenced in every class that uses logging via protected static readonly IAppender adonet = LoggingHelper.FindAppender("DB_Appender");. This function is implemented as follows:

   public static IAppender FindAppender(string appenderName)
    {
        foreach (IAppender appender in LogManager.GetRepository().GetAppenders())
        {
            if (appender.Name == appenderName)
            {
                return appender;
            }
        }

        return null;
    }

All works fine so far except two things:

  1. when the application starts up for the first time (or even after restarting the application), on the first run of each order, the log level seems to be set to ERROR even though it's set to DEBUG by default on creation of each instance and debugging the loggers shows otherwise.

  2. As well, every order can be triggered and stopped manually. When stopping the order, log4net stops logging stuff for this order, even though the respective C# / .NET instance of the logger and the order are still persisted and not deleted by GC or manually within the application. I have experimented with the BufferSize for the ADONetAppender, but this doesn't seem to do the trick. Is this something that log4net does intentionally to save ressources? Am I missing out on something rather obvious?

I could provide some excerpts from the source code if necessary but since this is an enterprise-grade application I'd rather not for now.

Mosh Pit
  • 318
  • 5
  • 14

0 Answers0