log4net.ext.json: ERROR Failed to find type [log4net.Layout.SerializedLayout, log4net.Ext.Json]

1.9k views Asked by At

I've installed the nuget package for log4net.Ext.Json and following the first steps instructions from the wiki.

However, I am getting the following error at runtime:

log4net:ERROR Failed to find type [log4net.Layout.SerializedLayout, log4net.Ext.Json]
System.IO.FileNotFoundException: Could not load file or assembly 'log4net.Ext.Json' or one of its dependencies. The system cannot find the file specified.
File name: 'log4net.Ext.Json'
   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.CreateObjectFromXml(XmlElement element, Type defaultTargetType, Type typeConstraint)

=== Pre-bind state information ===
LOG: DisplayName = log4net.Ext.Json
 (Partial)
WRN: Partial binding information was supplied for an assembly:
WRN: Assembly Name: log4net.Ext.Json | 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:///<MyProject>/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: <MyProject>\bin\Debug\log4net-googlecloudlogging-console.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:///<MyProject>/bin/Debug/log4net.Ext.Json.DLL.
LOG: Attempting download of new URL file:///<MyProject>/bin/Debug/log4net.Ext.Json/log4net.Ext.Json.DLL.
LOG: Attempting download of new URL file:///<MyProject>/bin/Debug/log4net.Ext.Json.EXE.
LOG: Attempting download of new URL file:///<MyProject>/bin/Debug/log4net.Ext.Json/log4net.Ext.Json.EXE.

log4net:ERROR Failed to create object to set param: layout

How can I fix this?

2

There are 2 answers

2
Peter On

The dll log4net.Ext.Json.dll is missing in your output/running directory or the dll log4net.Ext.Json.dll does not contain the class log4net.Layout.SerializedLayout. First check the dll and if it is not there copy it to the directory.

0
Robert Cutajar On

I'd like to know what framework you compile with? That version was not .NetStandard ready. Now we have release 2.0.8 which includes it. Try to update and if it still doesn't work, update your Q with more context.