首页 > 代码库 > log4net 存储到oracle 调试 Could not load type [log4net.Appender.OracleAppender]

log4net 存储到oracle 调试 Could not load type [log4net.Appender.OracleAppender]

近期在弄webfrom oracle 调用 log4net 開始调试时不出数据,打开了log4net 自己的debug功能后发现:


log4net: Logger [root] level set to [name="ALL",value=http://www.mamicode.com/-2147483648].

log4net: Loading Appender [OracleAppender] type: [log4net.Appender.OracleAppender]
log4net:ERROR Could not create Appender [OracleAppender] of type [log4net.Appender.OracleAppender]. Reported error follows.
System.TypeLoadException: Could not load type [log4net.Appender.OracleAppender]. Tried assembly [log4net, Version=1.2.13.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a] and all loaded assemblies
   在 log4net.Util.SystemInfo.GetTypeFromString(Assembly relativeAssembly, String typeName, Boolean throwOnError, Boolean ignoreCase)
   在 log4net.Util.SystemInfo.GetTypeFromString(String typeName, Boolean throwOnError, Boolean ignoreCase)
   在 log4net.Repository.Hierarchy.XmlHierarchyConfigurator.ParseAppender(XmlElement appenderElement)
log4net:ERROR Appender named [OracleAppender] not found.
log4net: Adding appender named [InfoAppender] to logger [root].

log4net: Hierarchy Threshold []


<log4net>
<!--<appender name="OracleAppender" type="log4net.Appender.OracleAppender">-->    发现把这句改成以下这句就ok了。


<appender name="AdoNetAppender_Oracle" type="log4net.Appender.AdoNetAppender">
<bufferSize value="http://www.mamicode.com/1" />


<!--<connectionType value="http://www.mamicode.com/Oracle.DataAccess.Client.OracleConnection, Oracle.DataAccess, Version=2.0.50727.3053, Culture=neutral, PublicKeyToken=b77a5c561934e089" />-->
<!--<connectionType value="http://www.mamicode.com/Oracle.DataAccess.Client.OracleConnection, System.Data.OracleClient, Version=2.0.50727.3053, Culture=neutral, PublicKeyToken=b77a5c561934e089" />-->
<connectionType value="http://www.mamicode.com/System.Data.OracleClient.OracleConnection, System.Data.OracleClient" />
<connectionType value="http://www.mamicode.com/System.Data.OracleClient.OracleConnection, System.Data.OracleClient" />


<connectionString value="http://www.mamicode.com/DATA SOURCE=ORCL;USER ID=BEFORVIPRESET;PASSWORD=BEFORVIPRESET"/>
<commandText value="http://www.mamicode.com/INSERT INTO BEFORVIPRESET.YHJ_LOG4NET (LOG_ID, LOG_DATE, LOG_LEVEL, LOG_IDENTITY, LOG_MESSAGE, LOG_EXCEPTION, LOG_LOGGER, LOG_SOURCE) VALUES (YHJ_LOG4NET_SEQ.nextval, :log_date, :log_level, :log_identity," />
<parameter>
<parameterName value="http://www.mamicode.com/:log_date" />
<dbType value="http://www.mamicode.com/DateTime" />
<layout type="log4net.Layout.RawTimeStampLayout">
<conversionPattern value="http://www.mamicode.com/%d{yyyy/MM/dd HH:mm:ss}" />
</layout>
</parameter>
<parameter>
<parameterName value="http://www.mamicode.com/:log_level" />
<dbType value="http://www.mamicode.com/String" />
<size value="http://www.mamicode.com/10" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="http://www.mamicode.com/%level" />
</layout>
</parameter>
<parameter>
<parameterName value="http://www.mamicode.com/:log_identity" />
<dbType value="http://www.mamicode.com/String" />
<size value="http://www.mamicode.com/100" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="http://www.mamicode.com/%identity" />
</layout>
</parameter>
<parameter>
<parameterName value="http://www.mamicode.com/:log_message" />
<dbType value="http://www.mamicode.com/String" />
<size value="http://www.mamicode.com/4000" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="http://www.mamicode.com/%m" />
</layout>
</parameter>
<parameter>
<parameterName value="http://www.mamicode.com/:log_exception" />
<dbType value="http://www.mamicode.com/String" />
<size value="http://www.mamicode.com/4000" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="http://www.mamicode.com/%exception" />
</layout>
</parameter>
<parameter>
<parameterName value="http://www.mamicode.com/:logger" />
<dbType value="http://www.mamicode.com/String" />
<size value="http://www.mamicode.com/255" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="http://www.mamicode.com/%logger" />
</layout>
</parameter>
<parameter>
<parameterName value="http://www.mamicode.com/:source" />
<dbType value="http://www.mamicode.com/String" />
<size value="http://www.mamicode.com/1000" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="http://www.mamicode.com/%file:%line" />
</layout>
</parameter>
</appender>


当中log4net里面仅仅有AdoNetAppender 而没有OracleAppender,除非你定义。

假设你自己定义。參考我上述应该能够的。

log4net 存储到oracle 调试 Could not load type [log4net.Appender.OracleAppender]