1. 程式人生 > >java專案模板-log4j

java專案模板-log4j

  1. log4j.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration PUBLIC "-//APACHE//DTD LOG4J 1.2//EN" "log4j.dtd">
<log4j:configuration>
    <appender name="FILE" class="org.apache.log4j.RollingFileAppender">
        <param name="file" value="${project.home}/logs/dispatchmanage.log"
/>
<param name="append" value="true"/> <param name="maxFileSize" value="100MB"/> <param name="maxBackupIndex" value="10"/> <layout class="org.apache.log4j.PatternLayout"> <param name='ConversionPattern' value='[%-5p][%d{yyyy/MM/dd HH:mm:ss}][%l][%m]%n'
/>
</layout> </appender> <appender name="Console" class="org.apache.log4j.ConsoleAppender"> <param name="Target" value="System.out"/> <layout class="org.apache.log4j.PatternLayout"> <param name='ConversionPattern' value='[%-5p][%d{yyyy/MM/dd HH:mm:ss}][%l][%m]%n'
/>
</layout> </appender> <!-- Application Loggers --> <!-- 3rdparty Loggers --> <!--example--> <!--<logger name="org.springframework.core">--> <!--<level value="info" />--> <!--</logger>--> <!-- Root Logger --> <root> <level value="debug" /> <appender-ref ref="Console" /> </root> </log4j:configuration>

2018-12-10