Uploaded image for project: 'Log4net'
  1. Log4net
  2. LOG4NET-307

New pattern AssemblyLocationPatternConverter

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 1.2.9, 1.2.10
    • Other
    • None

    Description

      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

      Attachments

        Activity

          People

            Unassigned Unassigned
            abuntxa Jon Abaunza
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: