I have created a custom appender to work alongside two other appenders. The
problem I have having is that the custom appender isn't receiving any logs.
My custom appender simply inherits from AppenderSkeleton. However, I have
also tried creating my own appender that implements IAppender.
My application is a Windows Form application, written in C# using VS2015. I
am targetting .Net 4.5.2. "Any CPU"
I am using Log4Net version v2.0.5 from NuGet (version 1.2.15.0)
Within the application config I have
<root>
<level value="DEBUG" />
<appender-ref ref="MemoryAppender" />
<appender-ref ref="RollingFileAppender" />
<appender-ref ref="AdoNetAppender" />
</root>
<appender name="MemoryAppender"
type="[namespace].CustomAppender,[assemblyname]">
</appender>
My custom appender is being found as the program stops at a break point in
the constructor. However, the overridden Append() is never called.
The OUTPUT window contains the following details:
Exception thrown: 'System.InvalidCastException' in log4net.dll
log4net:ERROR XmlHierarchyConfigurator: Could not create Appender
[MemoryAppender] of type [<namespace>.CustomAppender,<assemblyname>].
Reported error follows.
System.InvalidCastException: Unable to cast object of type
'<assemblyname>.CustomAppender' to type 'log4net.Appender.IAppender'.
at
log4net.Repository.Hierarchy.XmlHierarchyConfigurator.ParseAppender(XmlElement
appenderElement)
log4net:ERROR XmlHierarchyConfigurator: Appender named [MemoryAppender] not
found.
Any suggestions to fix this issue would be gratefully received.
--
View this message in context:
http://apache-logging.6191.n7.nabble.com/Issue-with-Custom-Appender-tp70625.html
Sent from the Log4net - Users mailing list archive at Nabble.com.