Hallo again ...

I was not able to reproduce your problem. The config runs without
errors on my system.

But I had some time to study the log4net sources and can tell you,
that there is totaly no way to configure 2 Loggers  with the same
name.

The reason: The Repository stores all Logers in a Hashtable; the
logger name is used as the key for this table, so it's impossible to
store two loggers with the same name. What happens in XmlConfig is
like this:

It loops through root xml elements. For every Logger element, it calls
getLogger(Name) to get the logger (wich will create a new logger or
return the allready created if exists). Level is set/overriden,
AppenderRefs are erased, and recreated.

In the end, your Logger is allways configured like the last definition
in configfile.

You can profe this very simple for yourself:
[assembly: log4net.Config.XmlConfigurator(ConfigFileExtension = "log4net")]
namespace ConsoleApplication1
{
   class Program
   {
       static void Main(string[] args)
       {
           foreach (log4net.Repository.Hierarchy.Logger  curLog in
log4net.LogManager.GetRepository().GetCurrentLoggers())
           {
               Console.WriteLine("logger {0} - level {1} ",
curLog.Name,curLog.Level);
               foreach (log4net.Appender.IAppender curAppender in
curLog.Appenders )
               {
                   Console.WriteLine("{0} - {1}", curAppender.Name,
curAppender.GetType().FullName);
               }
           }
           Console.ReadLine();
       }
   }
}

Hard to say why your FileAppender crashes. Are you using the target
file in other processes? Perhaps log4net is not able to open the
FileHandle and runs into the 'cannot write to closed appender'
exception?

Reply via email to