Log4NET SQL配置
<?xml version="1.0" encoding="utf-8" ?> <log4net> <logger name="SqlLogger"> <level value="ERROR" /> <appender-ref ref="ADONetAppender_SqlServer" /> </logger> <appender name="ADONetAppender_SqlServer" 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=服务器;initial catalog=数据库;integrated security=false;persist security info=True;User ID=用户名;Password=密码" /> <commandText value="insert into whptLog(LogDate,LogThread,LogLevel,LogLogger,LogMessage,LogErrorClass,LogLine) values(@date,@thread,@level,@logger,@message,@class,@line)" /> <parameter> <parameterName value="@date" /> <dbType value="DateTime" /> <layout type="log4net.Layout.RawTimeStampLayout" /> </parameter> <parameter> <parameterName value="@thread" /> <dbType value="String" /> <size value="20" /> <layout type="log4net.Layout.PatternLayout"> <conversionPattern value="%t" /> </layout> </parameter> <parameter> <parameterName value="@level" /> <dbType value="String" /> <size value="10" /> <layout type="log4net.Layout.PatternLayout"> <conversionPattern value="%-10p" /> </layout> </parameter> <parameter> <parameterName value="@logger" /> <dbType value="String" /> <size value="20" /> <layout type="log4net.Layout.PatternLayout"> <conversionPattern value="%logger" /> </layout> </parameter> <parameter> <parameterName value="@message" /> <dbType value="String" /> <size value="4000" /> <layout type="log4net.Layout.PatternLayout"> <conversionPattern value="%exception" /> </layout> </parameter> <parameter> <parameterName value="@class" /> <dbType value="String" /> <size value="100" /> <layout type="log4net.Layout.PatternLayout"> <conversionPattern value="%c" /> </layout> </parameter> <parameter> <parameterName value="@line" /> <dbType value="String" /> <size value="4000" /> <layout type="log4net.Layout.PatternLayout"> <conversionPattern value="文件:%F----->行:%L" /> </layout> </parameter> </appender> </log4net>