Reputation: 4259
I am trying to create a library for logging using log4net i installed log4net.async from Link and i am calling it from a console application to log into database and file.
It is giving the error in log4net internal log
log4net: Configuration update mode [Merge].
log4net: Loading Appender [asyncForwarder] type: [Log4Net.Async.AsyncForwardingAppender,Log4Net.Async]
log4net:ERROR Could not create Appender [asyncForwarder] of type [Log4Net.Async.AsyncForwardingAppender,Log4Net.Async]. Reported error follows.
System.IO.FileNotFoundException: Could not load file or assembly 'Log4Net.Async' or one of its dependencies. The system cannot find the file specified.
File name: 'Log4Net.Async'
at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMarkHandle stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName, ObjectHandleOnStack type)
at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName)
at System.RuntimeType.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark)
at System.Type.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase)
at log4net.Util.SystemInfo.GetTypeFromString(Assembly relativeAssembly, String typeName, Boolean throwOnError, Boolean ignoreCase)
at log4net.Util.SystemInfo.GetTypeFromString(String typeName, Boolean throwOnError, Boolean ignoreCase)
at log4net.Repository.Hierarchy.XmlHierarchyConfigurator.ParseAppender(XmlElement appenderElement)
=== Pre-bind state information ===
LOG: DisplayName = Log4Net.Async
(Partial)
WRN: Partial binding information was supplied for an assembly:
WRN: Assembly Name: Log4Net.Async | Domain ID: 1
WRN: A partial bind occurs when only part of the assembly display name is provided.
WRN: This might result in the binder loading an incorrect assembly.
WRN: It is recommended to provide a fully specified textual identity for the assembly,
WRN: that consists of the simple name, version, culture, and public key token.
WRN: See whitepaper http://go.microsoft.com/fwlink/?LinkId=109270 for more information and common solutions to this issue.
LOG: Appbase = file:///C:/Users/vmekaxp/Documents/Visual Studio 2013/Projects/LogForNetAsync/Test/bin/Debug/
LOG: Initial PrivatePath = NULL
Calling assembly : log4net, Version=1.2.13.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Users\vmekaxp\Documents\Visual Studio 2013\Projects\LogForNetAsync\Test\bin\Debug\Test.vshost.exe.Config
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///C:/Users/vmekaxp/Documents/Visual Studio 2013/Projects/LogForNetAsync/Test/bin/Debug/Log4Net.Async.DLL.
LOG: Attempting download of new URL file:///C:/Users/vmekaxp/Documents/Visual Studio 2013/Projects/LogForNetAsync/Test/bin/Debug/Log4Net.Async/Log4Net.Async.DLL.
LOG: Attempting download of new URL file:///C:/Users/vmekaxp/Documents/Visual Studio 2013/Projects/LogForNetAsync/Test/bin/Debug/Log4Net.Async.EXE.
LOG: Attempting download of new URL file:///C:/Users/vmekaxp/Documents/Visual Studio 2013/Projects/LogForNetAsync/Test/bin/Debug/Log4Net.Async/Log4Net.Async.EXE.
log4net:ERROR Appender named [asyncForwarder] not found.
log4net: Hierarchy Threshold []
log4net: No appenders could be found for logger [name] repository [log4net-default-repository]
log4net: Please initialize the log4net system properly.
log4net: Current AppDomain context information:
log4net: BaseDirectory : C:\Users\vmekaxp\Documents\Visual Studio 2013\Projects\LogForNetAsync\Test\bin\Debug\
log4net: FriendlyName : Test.vshost.exe
log4net: DynamicDirectory:
log4net: Shutdown called on Hierarchy [log4net-default-repository]
My config
<appender name="asyncForwarder" type="Log4Net.Async.AsyncForwardingAppender,Log4Net.Async">
<level value="INFO"></level>
<appender-ref ref="GeneralRollingFileAppender" />
<appender-ref ref="ErrorRollingFileAppender" />
<appender-ref ref="AdoNetAppender" />
<bufferSize value="200000" />
</appender>
<root>
<appender-ref ref="asyncForwarder" />
</root>
Upvotes: 0
Views: 1146
Reputation: 16609
Because the assembly is not being directly referenced in code, it is probably not being copied to the bin folder.
Try including it in the Visual Studio project but set its properties to
Another option is to try adding a reference to the Log4Net.Async.DLL directly to your top-level project (Console app).
Upvotes: 1