Log4net
  1. Log4net
  2. LOG4NET-343

ArgumentOutOfRangeException in log4net hierarchy on "." logger name

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.2.11
    • Fix Version/s: 1.2.12
    • Component/s: Core
    • Labels:
      None
    • Environment:
      Windows 32 bit, .NET 3.5 SP 1

      Description

      While configuring a logger with name ".", however wrong it may be, I stampled on uncaught exception.
      "Index was out of range. Must be non-negative and less than the size of the collection.
      Parameter name: startIndex"
      The problem code is at the first executable code line of UpdateParents(Logger log) method
      of log4net.Repository.Hierarchy.Hierarchy class.

      I am sure there is an easy fix.

      1. LOG4NET-343.patch
        3 kB
        Dominik Psenner

        Activity

        Hide
        Dominik Psenner added a comment -

        Unfortunately you did not provide a test case. Would you please check if this patch solves this issue?

        Show
        Dominik Psenner added a comment - Unfortunately you did not provide a test case. Would you please check if this patch solves this issue?
        Hide
        Dmitri Tchikine added a comment - - edited

        The actual test case was that this code does not throw any exception:
        log4net.LogManager.GetLogger(".");

        But of cause, there are more test cases:
        1) Any of these calls should not through exceptions either:
        log4net.LogManager.GetLogger("..A");
        log4net.LogManager.GetLogger("B....A");
        2) And it should be possible to configure a logger with one character name, and use it, so that a code like this would actually log a message:
        log4net.LogManager.GetLogger("A").Info("test");

        I am afraid that a fix, which simply ignores 1-character strings, does not meet such expectations.

        Show
        Dmitri Tchikine added a comment - - edited The actual test case was that this code does not throw any exception: log4net.LogManager.GetLogger("."); But of cause, there are more test cases: 1) Any of these calls should not through exceptions either: log4net.LogManager.GetLogger("..A"); log4net.LogManager.GetLogger("B....A"); 2) And it should be possible to configure a logger with one character name, and use it, so that a code like this would actually log a message: log4net.LogManager.GetLogger("A").Info("test"); I am afraid that a fix, which simply ignores 1-character strings, does not meet such expectations.
        Hide
        Stefan Bodewig added a comment -

        fixed with svn revision 1345560

        Show
        Stefan Bodewig added a comment - fixed with svn revision 1345560

          People

          • Assignee:
            Stefan Bodewig
            Reporter:
            Dmitri Tchikine
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development