You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4net-dev@logging.apache.org by "Chris Jerdonek (JIRA)" <ji...@apache.org> on 2008/05/25 01:19:55 UTC
[jira] Commented: (LOG4NET-136) logger conversionPattern
restriction doesn't work correctly for Generic classes
[ https://issues.apache.org/jira/browse/LOG4NET-136?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12599639#action_12599639 ]
Chris Jerdonek commented on LOG4NET-136:
----------------------------------------
> Now that generics have been around a while has anyone come up with a "standard" way of parsing generic string type names?
Given that a logger name can be a potentially arbitrary string, for the purposes of %logger{n}, I would shy away from doing too much on the assumption that the name is the result of calling type.FullName.
I think it might be simplest to apply %logger{n}'s "right-most" rule only to the maximal initial substring that "looks like" a conventional class. This can be simply the maximal initial consecutive segment of letters, numbers, underscores, and periods (since I believe letters, numbers, and underscores are the only characters that can be in a C# identifier.)
This would mean that the logger--
My.App.Package.TypeName`1[[My.App.Generic.ParameterTypeName, My.Assembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]
would generate the following for the pattern %logger{1}:
TypeName`1[[My.App.Generic.ParameterTypeName, My.Assembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]
On a related note, I'd also suggest that the group consider generating the default logger name for a type in a way other than simply calling type.FullName -- perhaps so it will look like "My.App.Package.TypeName<My.App.Generic.ParameterTypeName>" or "My.App.Package.TypeName<ParameterTypeName>", along the lines Tom was suggesting. I was thinking about suggesting this even before seeing this issue. That would be a nice convenience since .NET doesn't seem to provide a method or property like that already.
> logger conversionPattern restriction doesn't work correctly for Generic classes
> -------------------------------------------------------------------------------
>
> Key: LOG4NET-136
> URL: https://issues.apache.org/jira/browse/LOG4NET-136
> Project: Log4net
> Issue Type: Bug
> Affects Versions: 1.2.10
> Environment: Windows 2000 Professional, .NET Framework 2.0
> Reporter: Tom Crossland
> Priority: Minor
>
> <conversionPattern value="%date %-5level %logger{1} - %message%newline"/>
> Using the above conversion pattern for a logger of a Generic class (i.e. My.System.MyClass<My.System.MyObject>) will result in the following log output:
> 2008-01-17 21:54:48,968 INFO 0, Culture=neutral, PublicKeyToken=null]] - My error message
> Obviously, in this case it's not appropriate to just take the portion of the class name after the last '.' character.
> Thanks
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.