asp.net MVC日志插件Log4Net学习笔记二:保存日志到sqlserver的配置
1.写到sqlserver的配置:
<!--保存到SQLSERVER数据库日志--> <log4net> <appender name="AdoNetAppender" type="log4net.Appender.AdoNetAppender"> <!--<bufferSize value="10" />--> <connectionType value="System.Data.SqlClient.SqlConnection, System.Data, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/> <connectionString value="Server=localhost;UID=sa;PWD=8086;DataBase=daohang360;Max Pool Size=1000"/> <commandText value="INSERT INTO Log VALUES ([Date],[Thread],[Level],[Logger],[Message],[Exception]) (@log_date, @thread, @log_level, @logger, @message, @exception)" /> <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> <parameter> <parameterName value="@log_level" /> <dbType value="String" /> <size value="50" /> <layout type="log4net.Layout.PatternLayout"> <conversionPattern value="%level" /> </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="@message" /> <dbType value="String" /> <size value="4000" /> <layout type="log4net.Layout.PatternLayout"> <conversionPattern value="%message" /> </layout> </parameter> <parameter> <parameterName value="@exception" /> <dbType value="String" /> <size value="2000" /> <layout type="log4net.Layout.ExceptionLayout" /> </parameter> </appender> <root> <!-- Set this to "ERROR" before release --> <!--Highest: OFF->FATAL->RROR->WARN->INFO->DEBUG->ALL :Lowest --> <level value="ALL" /> <appender-ref ref="AdoNetAppender" /> <!-- <appender-ref ref="SmtpAppender" /> --> <!--<appender-ref ref="FileAppender" /> --> </root> </log4net>
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。