zoukankan      html  css  js  c++  java
  • 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>
  • 相关阅读:
    Algorithm Of Swift -- 4.合并两个有序数组
    Algorithm Of Swift -- 3.链表反转
    Algorithm Of Swift -- 2.字符串反转
    Algorithm Of Swift -- 1.两数之和
    1850984: Fix: crash when running am.jar without parameters
    微信公众号关联小程序,实现消息推送。
    NPOI根据Excel数据导入导出到Datatable中--帮助类
    OpenCvSharp+ZXing实现多个DataMatrix解析
    多数据源导致事务不生效
    android theme之Material的默认色和夜晚模式
  • 原文地址:https://www.cnblogs.com/herizai/p/7109858.html
Copyright © 2011-2022 走看看