我的 AdoNetAppender 有问题 - 它只是没有记录。我浏览了 log4net 手册和其他各种链接,但看不出我做错了什么。以下是我的配置文件以及我如何称呼它,因此将不胜感激!
<appender name="AdoNetAppender" type="log4net.Appender.AdoNetAppender">
<bufferSize value="1" />
<connectionType value="System.Data.SqlClient.SqlConnection, System.Data, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<connectionString value="***" />
<commandText value="dbo.spx_CreatePageLog" />
<commandType value="StoredProcedure" />
<!--<parameter>
<parameterName value="@log_date" />
<dbType value="DateTime" />
<layout type="log4net.Layout.RawTimeStampLayout">
<conversionPattern value="%message" />
</layout>
</parameter>-->
<parameter>
<parameterName value="@HTTPMethod" />
<dbType value="String" />
<size value="10" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%message" />
</layout>
</parameter>
<parameter>
<parameterName value="@URI" />
<dbType value="String" />
<size value="512" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%URI{URI}" />
</layout>
</parameter>
<parameter>
<parameterName value="@RequestData" />
<dbType value="String" />
<size value="1024" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%RequestData{RequestData}" />
</layout>
</parameter>
<parameter>
<parameterName value="@UserID" />
<dbType value="int" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%UserID{UserID}" />
</layout>
</parameter>
<parameter>
<parameterName value="@UserToDealerID" />
<dbType value="int" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%UserToDealerID{UserToDealerID}" />
</layout>
</parameter>
<parameter>
<parameterName value="@AdminID" />
<dbType value="String" />
<size value="256" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%AdminID{AdminID}" />
</layout>
</parameter>
<parameter>
<parameterName value="@SessionID" />
<dbType value="String" />
<size value="256" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%SessionID{SessionID}" />
</layout>
</parameter>
<parameter>
<parameterName value="@BrowserInfo" />
<dbType value="String" />
<size value="1024" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%BrowserInfo{BrowserInfo}" />
</layout>
</parameter>
<!--<parameter>
<parameterName value="@exception" />
<dbType value="String" />
<size value="2000" />
<layout type="log4net.Layout.ExceptionLayout" />
</parameter>-->
</appender>
<root>
<level value="DEBUG" />
<appender-ref ref="AdoNetAppender" />
</root>
string RequestData = auditModel.ParameterValues.GetDictionaryIntoString<string>();
string BrowserInfo = auditModel.BrowserInfo.GetDictionaryIntoString<string>();
//log4net.LogicalThreadContext.Properties["HTTPMethod"] = auditModel.Method;
log4net.GlobalContext.Properties["URI"] = auditModel.RequestUrl;
log4net.GlobalContext.Properties["RequestData"] = RequestData;
log4net.GlobalContext.Properties["UserID"] = auditModel.UserID;
log4net.GlobalContext.Properties["UserToDealerID"] = auditModel.UserToDealerID;
log4net.GlobalContext.Properties["AdminID"] = auditModel.AdminID;
log4net.GlobalContext.Properties["SessionID"] = "123456"; //auditModel.SessionID;
log4net.GlobalContext.Properties["BrowserInfo"] = BrowserInfo;
Logger.Debug(auditModel.Method);