首页 > 代码库 > Log4net使用(二)
Log4net使用(二)
转:http://www.cnblogs.com/basilwang/archive/2006/06/09/421868.html
Log4net同时按照日期和大小生成RollingFile和访问Sybase数据库配置
1. Log4net同时按照日期和大小生成RollingFile
<appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender"> <file value="test.log" /> <appendToFile value="true" /> <rollingStyle value="Composite" /> <datePattern value=".yyyy_MM_dd" /> <maxSizeRollBackups value="10" /> <maximumFileSize value="10000" /> <staticLogFileName value="false" /> <layout type="log4net.Layout.PatternLayout"> <header value="[Header] " /> <footer value="[Footer] " /> <conversionPattern value="%date %type %file %line %method %location %class %C %F %L %l %M" /> </layout> </appender> 这样生成的日志类似test.log.2006_06_09,test.log.2006_06_08,如果哪一天的日志超过10000,那么日志名为test.log.2006_06_10.1、test.log.2006_06_10.2 .......
2.访问Sybase数据库配置
<appender name="ADONetAppender_Sybase1" type="log4net.Appender.AdoNetAppender"> <bufferSize value="1" /> <connectionType value="System.Data.Odbc.OdbcConnection, System.Data, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> <connectionString value="Driver={SYBASE SYSTEM 11};Srvr=basil;Uid=sa;Pwd=;DB=AddressBook" /> <commandText value="Log_add ? ,? , ?, ?, ?" /> <commandType value="StoredProcedure" /> <parameter> <parameterName value="@log_date" /> <dbType value="DateTime" /> <layout type="log4net.Layout.PatternLayout"> <conversionPattern value="%date{yyyy-MM-dd hh:mm:ss}" /> </layout> </parameter> <parameter> <parameterName value="@thread" /> <dbType value="String" /> <size value="255" /> <layout type="log4net.Layout.PatternLayout"> <conversionPattern value="%thread -just for test" /> </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="255" /> <layout type="log4net.Layout.PatternLayout"> <conversionPattern value="%message" /> </layout> </parameter> </appender>
Log4net使用(二)
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。