我似乎无法正确设置配置。有人有任何提示吗?
配置文件:
我添加了
<section name="log4net"
type="log4net.Config.Log4NetConfigurationSectionHandler, log4net">
在配置部分。
添加了log4net appender
<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="data source=[myServer];Initial Catalog=Log4Net;Integrated Security=SSPI;"/>
<commandText value="dbo.TestInsertNoParams @log_date"></commandText>
<commandType value="StoredProcedure"></commandType>
<parameter>
<parameterName value="@log_date" />
<dbType value="DateTime" />
<layout type="log4net.Layout.RawTimeStampLayout" />
</parameter>
<parameter>
<parameterName value="@thread" />
<dbType value="String" />
<size value="255" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%thread" />
</layout>
</parameter>
</appender>
<root>
<level value="ALL" />
<appender-ref ref="AdoNetAppender" />
</root>
</log4net>
我的前端代码是:
private static log4net.ILog Log { get; set; }
ILog log = log4net.LogManager.GetLogger(typeof(currentClass));
log.Info("test");
global.asax.cs:
log4net.Config.XmlConfigurator.Configure();
我可以通过其他操作很好地连接到该数据库,我可以手动运行insert语句并且运行正常,但没有任何保存....