如何解决log4net:ERROR Could not create Appender [aiAppender] of type
How to solve log4net:ERROR Could not create Appender [aiAppender] of type
我有 .net core 3.1 控制台应用程序,它引用了一个 .net class 库项目。
我遇到以下异常。
log4net:ERROR Could not create Appender [aiAppender] of type
[Microsoft.ApplicationInsights.Log4NetAppender.ApplicationInsightsAppender,
Microsoft.ApplicationInsights.Log4NetAppender]. Reported error
follows. System.IO.FileNotFoundException: Could not load file or
assembly 'Microsoft.ApplicationInsights.Log4NetAppender,
Culture=neutral, PublicKeyToken=null'. The system cannot find the file
specified. File name: 'Microsoft.ApplicationInsights.Log4NetAppender,
Culture=neutral, PublicKeyToken=null' at
System.RuntimeTypeHandle.GetTypeByName(String name, Boolean
throwOnError, Boolean ignoreCase, StackCrawlMarkHandle stackMark,
ObjectHandleOnStack assemblyLoadContext, Boolean
loadTypeFromPartialName, ObjectHandleOnStack type, ObjectHandleOnStack
keepalive) at System.RuntimeTypeHandle.GetTypeByName(String name,
Boolean throwOnError, Boolean ignoreCase, StackCrawlMark& stackMark,
AssemblyLoadContext assemblyLoadContext, Boolean
loadTypeFromPartialName) at System.RuntimeType.GetType(String
typeName, Boolean throwOnError, Boolean ignoreCase, 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)
log4net:ERROR Appender named [aiAppender] not found.
App.config:
<log4net>
<root>
<level value="ALL" />
<appender-ref ref="aiAppender" />
</root>
<appender name="aiAppender" type="Microsoft.ApplicationInsights.Log4NetAppender.ApplicationInsightsAppender, Microsoft.ApplicationInsights.Log4NetAppender">
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%message%newline" />
</layout>
</appender>
</log4net>
为了解决这个问题,我尝试从 NuGet 包管理器 Microsoft.ApplicationInsights.Log4NetAppender
添加一个包,但是在添加这个包时出现以下错误。
Failed to fetch results from V2 feed at
'http://fxnugetserver.azurewebsites.net/nuget/FindPackagesById()?id='runtime.ubuntu.14.04-x64.runtime.native.System.Security.Cryptography.OpenSsl'&semVerLevel=2.0.0'
with following message : The specified path, file name, or both are
too long. The fully qualified file name must be less than 260
characters, and the directory name must be less than 248 characters.
The specified path, file name, or both are too long. The fully
qualified file name must be less than 260 characters, and the
directory name must be less than 248 characters.
但是我的项目路径就是J:\fx-core
请帮我解决这个问题
我刚刚向两个项目添加了 log4net
包,现在错误消失了。
我有 .net core 3.1 控制台应用程序,它引用了一个 .net class 库项目。
我遇到以下异常。
log4net:ERROR Could not create Appender [aiAppender] of type [Microsoft.ApplicationInsights.Log4NetAppender.ApplicationInsightsAppender, Microsoft.ApplicationInsights.Log4NetAppender]. Reported error follows. System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.ApplicationInsights.Log4NetAppender, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified. File name: 'Microsoft.ApplicationInsights.Log4NetAppender, Culture=neutral, PublicKeyToken=null' at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, StackCrawlMarkHandle stackMark, ObjectHandleOnStack assemblyLoadContext, Boolean loadTypeFromPartialName, ObjectHandleOnStack type, ObjectHandleOnStack keepalive) at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, StackCrawlMark& stackMark, AssemblyLoadContext assemblyLoadContext, Boolean loadTypeFromPartialName) at System.RuntimeType.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase, 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)
log4net:ERROR Appender named [aiAppender] not found.
App.config:
<log4net>
<root>
<level value="ALL" />
<appender-ref ref="aiAppender" />
</root>
<appender name="aiAppender" type="Microsoft.ApplicationInsights.Log4NetAppender.ApplicationInsightsAppender, Microsoft.ApplicationInsights.Log4NetAppender">
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%message%newline" />
</layout>
</appender>
</log4net>
为了解决这个问题,我尝试从 NuGet 包管理器 Microsoft.ApplicationInsights.Log4NetAppender
添加一个包,但是在添加这个包时出现以下错误。
Failed to fetch results from V2 feed at 'http://fxnugetserver.azurewebsites.net/nuget/FindPackagesById()?id='runtime.ubuntu.14.04-x64.runtime.native.System.Security.Cryptography.OpenSsl'&semVerLevel=2.0.0' with following message : The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters. The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.
但是我的项目路径就是J:\fx-core
请帮我解决这个问题
我刚刚向两个项目添加了 log4net
包,现在错误消失了。