[
https://issues.apache.org/jira/browse/LOG4NET-580?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16226799#comment-16226799
]
Dominik Psenner commented on LOG4NET-580:
-----------------------------------------
Hi Timothy,
thanks for the report. The method in question could definitely be hardened
against bad input but I would like to talk about any changes before starting
off to fix this. Would you please outline for me how you expect log4net to
behave when a logger name starts with a dot or when a logger name contains
multiple dots without any other characters in between to create a hierarchy?
These are examples I can think of:
* ".Name": could be interpreted as ["", "Name"] or ["Name"]
* "Name.": could be interpreted as ["Name", ""] or ["Name"]
* "My..LoggerName": could be interpreted as ["My", "", "LoggerName"] or ["My",
"LoggerName"]
To me all of these are invalid logger names because they can be interpreted in
more than one logger hierarchy and are thus ambiguous. Thus to me these logger
names should be fixed and should never hit a production environment. Therefore
I'm not even sure about whether the framework should swallow any exception that
such a bad logger name would cause. The framework could however throw a
ArgumentException with a better exception message, explaining the situation.
Something along the lines of "Invalid logger name: {loggerName} starts with one
or more dots." and "Invalid logger name: {loggerName} ends with one or more
dots." and "Invalid logger name: {loggerName} contains a substring of at least
two dots." would probably do.
> ArgumentOutOfRangeException - When logger name begins with character '.'
> ------------------------------------------------------------------------
>
> Key: LOG4NET-580
> URL: https://issues.apache.org/jira/browse/LOG4NET-580
> Project: Log4net
> Issue Type: Bug
> Components: Core
> Affects Versions: 1.2.15, 2.0.6, 2.0.7, 2.0.8
> Reporter: Timothy Fuller
>
> When you try to get a logger and supply a name which begins with the '.'
> character for example ".Test" the code crashes in : at
> log4net.Repository.Hierarchy.Hierarchy.UpdateParents(Logger log)
> System.ArgumentOutOfRangeException: Index was out of range. Must be
> non-negative and less than the size of the collection.
> Parameter name: startIndex
> at System.String.LastIndexOf(Char value, Int32 startIndex, Int32 count)
> 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(String repository, String name)
> at log4net.LogManager.GetLogger(String repository, String name)
>
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)