近期在弄webfrom oracle 调用 log4net 開始调试时不出数据,打开了log4net 自己的debug功能后发现:
log4net: Logger [root] level set to [name="ALL",value=-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="1" />
<!--<connectionType value="Oracle.DataAccess.Client.OracleConnection, Oracle.DataAccess, Version=2.0.50727.3053, Culture=neutral, PublicKeyToken=b77a5c561934e089" />-->
<!--<connectionType value="Oracle.DataAccess.Client.OracleConnection, System.Data.OracleClient, Version=2.0.50727.3053, Culture=neutral, PublicKeyToken=b77a5c561934e089" />-->
<connectionType value="System.Data.OracleClient.OracleConnection, System.Data.OracleClient" />
<connectionType value="System.Data.OracleClient.OracleConnection, System.Data.OracleClient" />
<connectionString value="DATA SOURCE=ORCL;USER ID=BEFORVIPRESET;PASSWORD=BEFORVIPRESET"/>
<commandText value="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,
:log_message, :log_exception, :logger, :source)" />
<parameter>
<parameterName value=":log_date" />
<dbType value="DateTime" />
<layout type="log4net.Layout.RawTimeStampLayout">
<conversionPattern value="%d{yyyy/MM/dd HH:mm:ss}" />
</layout>
</parameter>
<parameter>
<parameterName value=":log_level" />
<dbType value="String" />
<size value="10" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%level" />
</layout>
</parameter>
<parameter>
<parameterName value=":log_identity" />
<dbType value="String" />
<size value="100" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%identity" />
</layout>
</parameter>
<parameter>
<parameterName value=":log_message" />
<dbType value="String" />
<size value="4000" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%m" />
</layout>
</parameter>
<parameter>
<parameterName value=":log_exception" />
<dbType value="String" />
<size value="4000" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%exception" />
</layout>
</parameter>
<parameter>
<parameterName value=":logger" />
<dbType value="String" />
<size value="255" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%logger" />
</layout>
</parameter>
<parameter>
<parameterName value=":source" />
<dbType value="String" />
<size value="1000" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%file:%line" />
</layout>
</parameter>
</appender>
当中log4net里面仅仅有AdoNetAppender 而没有OracleAppender,除非你定义。
假设你自己定义。參考我上述应该能够的。