• 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>
  • 相关阅读:
    Knockout.Js官网学习(visible绑定)
    Entity Framework 简单增删改操作
    Knockout.Js官网学习(数组observable)
    Knockout.Js官网学习(监控属性Observables)
    Entity Framework 简单查询
    Java 使用getClass().getResourceAsStream()方法获取资源
    Virtualbox [The headers for the current running kernel were not found] (操作过程后还是失败,显示相同问题)
    为什么要在linux命令前加上 ./
    Redis need tcl 8.5 or newer
    JDK和Tomcat部署时,版本不同的问题解决
  • 原文地址:https://www.cnblogs.com/herizai/p/7109858.html
Copyright © 2020-2023  润新知