[
https://issues.apache.org/jira/browse/LOG4NET-136?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12713849#action_12713849 ]
Ron Grabowski commented on LOG4NET-136:
---------------------------------------
The csLogger class can test to see if the logger is a CLR generic type:
// Spring.Core.TypeResolution.GenericArgumentsHolder
private static readonly Regex ClrPattern = new Regex(
"^"
+ @"(?'name'\w[\w\d\.]+)"
+ @"`\d+\s*\["
+ @"(?'args'(?>[^\[\]]+|\[(?<DEPTH>)|\](?<-DEPTH>))*(?(DEPTH)(?!)))"
+ @"\]"
+ @"(?'remainder'.*)"
+ @"$"
, RegexOptions.CultureInvariant | RegexOptions.Compiled
);
before it attempts to convert it to the more familiar C# < > syntax.
I'd like to keep the %csLogger{2} notation simple for now and apply the truncation to both the outer and inner classes. How about adding a property that removes the often redundant System prefix so this snippet of C#:
private ILog log = LogManager.GetLogger(typeof(Company.WidgetManagement.Model.MyObject<int>));
will look like this in the log file:
%csLogger{2,RemoveSystemPrefix=true}
Model.MyObject<Int32>
instead of:
Model.MyObject<System.Int32>
I keep referring to csLogger and vbLogger because we don't have a way of determining if the created Type was written in C# or VB. We have to put the burden on the person reading the logs.
The person reading the logs must also be aware that the verboseness of the CLR generic type syntax was chosen for a reason and that by dumbing that syntax down to the simpler "List<MyObject>" you potentially loose out on knowing what exact version of MyObject (in terms of what versioned assembly it came from). Its probably a minor point for most people but its worth noting.
I think a string parser to convert the CLR notation into C#/VB notation is the way to go...
> 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
> Assignee: Ron Grabowski
> Priority: Minor
> Fix For: 1.2.11
>
> Attachments: ConsoleApplication3-GenericPrettyPrinter.zip
>
>
> <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.