logging-log4net-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stefan Bodewig (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (LOG4NET-545) Inheriting from BufferingForwardingAppender throws in .NET Core
Date Sun, 15 Jan 2017 15:38:26 GMT

    [ https://issues.apache.org/jira/browse/LOG4NET-545?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15823172#comment-15823172
] 

Stefan Bodewig commented on LOG4NET-545:
----------------------------------------

The exception says it is trying to load the type from {{log4net}}, which most likely is not
the assembly where {{MyBufferingAppender}} is defined. Does it work if you use

{code}
<appender name="MyBufferingAppender" type="SomeNamespace.MyAppender,YOUR-ASSEMBLY-NAME">
....
{code}

or even a fully qualified type name (including assembly version, culture and potentially public
key token) instead?

> Inheriting from BufferingForwardingAppender throws in .NET Core
> ---------------------------------------------------------------
>
>                 Key: LOG4NET-545
>                 URL: https://issues.apache.org/jira/browse/LOG4NET-545
>             Project: Log4net
>          Issue Type: Bug
>          Components: Appenders
>    Affects Versions: 2.0.7
>            Reporter: Nima Ara
>            Priority: Critical
>
> I am in the process of migrating [Easy.Logger | https://github.com/NimaAra/Easy.Logger]
to _.NET Core_.
> When inheriting from the {{BufferingForwardingAppender}}:
> {code}
> public sealed class MyAppender : BufferingForwardingAppender
> {
> 	protected override void SendBuffer(LoggingEvent[] events)
> 	{
> 		base.SendBuffer(events);
> 	}
> }
> {code}
> Using the following config:
> {code:xml}
> <?xml version="1.0" encoding="utf-8" ?>
> <log4net>
>   <root>
>     <level value="ALL"/>
>     <appender-ref ref="MyBufferingAppender"/>    
>   </root>
>   <appender name="MyBufferingAppender" type="SomeNamespace.MyAppender">
>     <lossy value="false" />
>     <bufferSize value="512" />
>     <appender-ref ref="RollingFile"/>
>   </appender>
> ... rolling file appender skipped ...
> </log4net>
> {code}
> Throws:
> {code:none}
> log4net:ERROR Could not create Appender [MyBufferingAppender] of type [SomeNamespace.MyAppender].
Reported error follows.
> System.TypeLoadException: Could not load type 'SomeNamespace.MyAppender' from assembly
'log4net, Version=2.0.7.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a'.
>    at System.Reflection.RuntimeAssembly.GetType(RuntimeAssembly assembly, String name,
Boolean throwOnError, Boolean ignoreCase, ObjectHandleOnStack type, ObjectHandleOnStack keepAlive)
>    at System.Reflection.RuntimeAssembly.GetType(String name, Boolean throwOnError, Boolean
ignoreCase)
>    at log4net.Repository.Hierarchy.XmlHierarchyConfigurator.ParseAppender(XmlElement
appenderElement)
> log4net:ERROR Appender named [MyBufferingAppender] not found.
> {code}
> The same code and config runs file in the full framework.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message