Saturday, February 04, 2012
 
The best way to analyze your logs! Minimize
 Log4Net Mail archive   

The Log4Net mailing list is a great source of information about using log4Net, in this forum we collect all the messages in the log4net user list and some selected threads from the developer list.

Subject: Dot in logger name is causing log4net to throw exception
Prev Next
You are not authorized to post a reply.

Author Messages
Sascha Hamacher

03/25/2009 7:36 PM  

Hello,
first of all thank you for the very good logging framework.
While working with Log4Net 1.2.10 I experienced the following problem:

When the logger name starts with a ".", LogManager.GetLogger fails with
the following exception:

System.ArgumentOutOfRangeException was unhandled
 Message="Index was out of range. Must be non-negative and less than the
size of the collection.\r\nParameter name: startIndex"
 Source="mscorlib"
 ParamName="startIndex"
 StackTrace:
      at System.String.LastIndexOf(Char value, Int32 startIndex, Int32
count)
      at System.String.LastIndexOf(Char value, Int32 startIndex)
      at log4net.Repository.Hierarchy.Hierarchy.UpdateParents(Logger log)
      at log4net.Repository.Hierarchy.Hierarchy.GetLogger(String name,
ILoggerFactory factory)
      at log4net.Repository.Hierarchy.Hierarchy.GetLogger(String name)
      at log4net.Core.LoggerManager.GetLogger(Assembly
repositoryAssembly, String name)
      at log4net.LogManager.GetLogger(Assembly repositoryAssembly,
String name)
      at log4net.LogManager.GetLogger(String name)
      at ReproCaseLog4Net.Program.Main(String[] args) in
C:\Users\hamacs01\Documents\Visual Studio
2008\Projects\ReproCaseLog4Net\ReproCaseLog4Net\Program.cs:line 20
      at System.AppDomain._nExecuteAssembly(Assembly assembly, String[]
args)
      at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence
assemblySecurity, String[] args)
      at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
      at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
      at System.Threading.ExecutionContext.Run(ExecutionContext
executionContext, ContextCallback callback, Object state)
      at System.Threading.ThreadHelper.ThreadStart()
 InnerException:


The following code of a simple command line program reproduces the
problem for me:


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using log4net.Appender;
using log4net.Config;
using log4net;
using log4net.Layout;

namespace ReproCaseLog4Net
{
 class Program
 {
   static void Main( string[] args )
   {
     BasicConfigurator.Configure( new ConsoleAppender()
     {
       Layout = new SimpleLayout()
     } );
     ILog log = LogManager.GetLogger( ".MyLogger" ); // <<--- the
exception is thrown here
     log.Error( "ErrorMessage" );
     Console.ReadLine();
   }
 }
}




Best regards,
Sascha Hamacher


You are not authorized to post a reply.
Forums > Log4Net > Log4Net Mail archive > Dot in logger name is causing log4net to throw exception



ActiveForums 3.7

 

 

 

 

 

 

 

 

Log4Net Dashboard

Log analysis and monitoring made easy!

Log4Net Dashboard is a log viewer that can read log statements from a variety of logging output targets.

You can download a free developer version.

  

Check it out!

On the demonstration site you can try it  with live data.demo.l4ndash.com - Try Log4Net Dashboard with live data

The mail archive is a copy of all the mail sent to the mail address: log4net-user@logging.apache.org, organized as a forum.

If you would like to participate in the mail list, send a mail to log4net-user-subscribe@logging.apache.org.

More information about the mailing list is available on: http://logging.apache.org/log4net/support.html

 

A complete topic list is available and can be viewed here (warning, it takes some time to load)

 

Copyright 2005-2008 by FaktNet AS Terms Of Use Privacy Statement