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

Custom Appender throws exception to user when I use %type in ConversionPattern

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Blocker
    • Resolution: Fixed
    • Affects Version/s: 2.0.7
    • Fix Version/s: 2.1.0
    • Component/s: None
    • Labels:
      None

      Description

      When I setup my custom appender, I use the following ConversionPattern:

      <layout type="log4net.Layout.PatternLayout">
      <param name="ConversionPattern" value="%m%n %type" />
      </layout>

      In my custom appender's "Append()" method, the "RenderLoggingEvent" is throwing the exception below
      Here's how I am calling the RenderLoggingEvent method:

      protected override void Append(LoggingEvent loggingEvent)

      { ... var text = RenderLoggingEvent(loggingEvent); ... }

      Here is the exception I am getting:

      System.NullReferenceException was unhandled by user code
      HResult=-2147467261
      Message=Object reference not set to an instance of an object.
      Source=log4net
      StackTrace:
      at log4net.Layout.Pattern.TypeNamePatternConverter.GetFullyQualifiedName(LoggingEvent loggingEvent) in c:\log4net\tags\2.0.7RC1\src\Layout\Pattern\TypeNamePatternConverter.cs:line 51
      at log4net.Layout.Pattern.NamedPatternConverter.Convert(TextWriter writer, LoggingEvent loggingEvent) in c:\log4net\tags\2.0.7RC1\src\Layout\Pattern\NamedPatternConverter.cs:line 125
      at log4net.Util.PatternConverter.Format(TextWriter writer, Object state) in c:\log4net\tags\2.0.7RC1\src\Util\PatternConverter.cs:line 173
      at log4net.Layout.PatternLayout.Format(TextWriter writer, LoggingEvent loggingEvent) in c:\log4net\tags\2.0.7RC1\src\Layout\PatternLayout.cs:line 1117
      at log4net.Appender.AppenderSkeleton.RenderLoggingEvent(LoggingEvent loggingEvent) in c:\log4net\tags\2.0.7RC1\src\Appender\AppenderSkeleton.cs:line 705
      at MyAppender.MyAppender.Append(LoggingEvent loggingEvent) in E:\svn\trunk\MyAppender\MyAppender.cs:line 67
      at log4net.Appender.AppenderSkeleton.DoAppend(LoggingEvent loggingEvent) in c:\log4net\tags\2.0.7RC1\src\Appender\AppenderSkeleton.cs:line 317
      InnerException:

        Attachments

          Activity

            People

            • Assignee:
              nachbarslumpi Dominik Psenner
              Reporter:
              sparky2708 Denis Abramov
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: