You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by "Ralph Goers (Jira)" <ji...@apache.org> on 2020/04/04 22:30:07 UTC

[jira] [Updated] (LOG4NET-307) New pattern AssemblyLocationPatternConverter

     [ https://issues.apache.org/jira/browse/LOG4NET-307?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Ralph Goers updated LOG4NET-307:
--------------------------------

LOG4NET is now dormant.  

> New pattern AssemblyLocationPatternConverter
> --------------------------------------------
>
>                 Key: LOG4NET-307
>                 URL: https://issues.apache.org/jira/browse/LOG4NET-307
>             Project: Log4net
>          Issue Type: New Feature
>          Components: Other
>    Affects Versions: 1.2.9, 1.2.10
>            Reporter: Jon Abaunza
>            Priority: Major
>             Fix For: 1.2/2.0 Maintenance Release
>
>
> It would be really easy and nice, to hace the AssemblyLocationPatternConverter that would allow to retrieve the assembly of the Caller.
> using System;
> using System.Text;
> using System.IO;
> using log4net.Core;
> namespace log4net.Layout.Pattern
> {	internal sealed class AssemblyLocationPatternConverter : PatternLayoutConverter 
> 	{		override protected void Convert(TextWriter writer, LoggingEvent loggingEvent)
> 		{
> 			writer.Write(loggingEvent.LocationInformation.AssemblyName);
> 		}	
>                 }
> }	
> It just would need the retrieval of the Assembly Name in the LocationInfo (new property AssemblyName and the retrieval in the constructor)
> ...Retrieval....
> m_assembly = method.Module.Assembly.FullName;
> ... 
> After this... it just would be needed to register the new pattern so that it would be recognized. (Added in the static constructor of PatternLayout)
> ....
> s_globalRulesRegistry.Add("assembly", typeof(AssemblyLocationPatternConverter));
> ....
> With a conversion pattern like the following
> <conversionPattern value="%assembly"/>
> We could get the following log:
> WindowsFormsApplication3, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null



--
This message was sent by Atlassian Jira
(v8.3.4#803005)