[
https://issues.apache.org/jira/browse/LOG4NET-553?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15858517#comment-15858517
]
Jean-Francois Beaulac commented on LOG4NET-553:
-----------------------------------------------
Sure,
I have noticed that the TraceAppender already does something similar to what
you suggested, so I did something similar.
I added a Category property to the DebugAppender of type LayoutSkeleton, it
defaults to {{new PatternLayout("%logger")}}
I created a LayoutClass named ReturnsNullLayout that derives from
LayoutSkeleton, in which all methods are NOOP. In LayoutSkeleton I made the
Format(LoggingEvent) method virtual to be able to override it in the
ReturnsNullLayout class and avoid creating a StringWriter instance for no
reason.
I wrote tests for the DebugAppender, none existed. I copied the TraceAppender
tests. I also wrote a test for the ReturnsNullLayout class. I ran the tests and
they all passed.
My patch also adds the files to the vs2012/2010 and 2008 solutions. I can test
that 2012 and 2010 build, but I dont have 2008 to test if it builds. I also
modified the .NET core project files which I am not familiar with, but it seems
to work in visual studio.
Let me know what you think.
Thanks,
Jf
> DebugAppender configuration should give the possibility to disable outputting
> loggerName as category
> ----------------------------------------------------------------------------------------------------
>
> Key: LOG4NET-553
> URL: https://issues.apache.org/jira/browse/LOG4NET-553
> Project: Log4net
> Issue Type: New Feature
> Components: Appenders
> Affects Versions: 2.0.7
> Reporter: Jean-Francois Beaulac
> Attachments: log4net-DebugAppenderCategory.patch,
> OutputCategoryParam-DebugAppender.cs.patch
>
>
> The DebugAppender always uses the
> {{System.Diagnostics.Debug.Write(string,string)}} overload passing in the
> loggername as the category parameter.
> It should be possible to omit the category parameter if having the loggername
> as category is not desired.
> Attached is a patch implementing the desired new feature, which would be
> activated by configuration:
> {code:xml}
> <appender name="DEBUG" type="log4net.Appender.DebugAppender">
> <outputCategory value="false"/>
> <layout type="log4net.Layout.PatternLayout">
> <conversionPattern value="%-5level: %message%newline"/>
> </layout>
> </appender>
> {code}
> In my patch, the outputCategory parameter defaults to true, so the behavior
> doesnt change unless the new configuration is used.
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)