log4j2.xml的完整





<configuration status="WARN" monitorInterval="30">
    <properties>
        <property name="LOG_HOME">F:/logsproperty>
        <Property name="PATTERN">%d %-5p [%t] %C{1} (%F:%L) - %m%nProperty>
    properties>
    
    <appenders>
        
        <console name="Console" target="SYSTEM_OUT">
            
            <PatternLayout pattern="${PATTERN}"/>
        console>
        
        <File name="log" fileName="log/test.log" append="false">
            <PatternLayout pattern="${PATTERN}"/>
        File>
        
        <RollingFile name="RollingFileInfo" fileName="${LOG_HOME}/info.log"
                     filePattern="${LOG_HOME}/$${date:yyyy-MM}/info-%d{yyyy-MM-dd}-%i.log">
            
            <ThresholdFilter level="info" onMatch="ACCEPT" onMismatch="DENY"/>
            <PatternLayout pattern="${PATTERN}"/>
            <Policies>
                <TimeBasedTriggeringPolicy/>
                <SizeBasedTriggeringPolicy size="100MB"/>
            Policies>
        RollingFile>
        <RollingFile name="RollingFileWarn" fileName="${LOG_HOME}/warn.log"
                     filePattern="${LOG_HOME}/$${date:yyyy-MM}/warn-%d{yyyy-MM-dd}-%i.log">
            <ThresholdFilter level="warn" onMatch="ACCEPT" onMismatch="DENY"/>
            <PatternLayout pattern="${PATTERN}"/>
            <Policies>
                <TimeBasedTriggeringPolicy/>
                <SizeBasedTriggeringPolicy size="100MB"/>
            Policies>
            
            <DefaultRolloverStrategy max="20"/>
        RollingFile>
        <RollingFile name="RollingFileError" fileName="${LOG_HOME}/error.log"
                     filePattern="${LOG_HOME}/$${date:yyyy-MM}/error-%d{yyyy-MM-dd}-%i.log">
            <ThresholdFilter level="error" onMatch="ACCEPT" onMismatch="DENY"/>
            <PatternLayout pattern="${PATTERN}"/>
            <Policies>
                <TimeBasedTriggeringPolicy/>
                <SizeBasedTriggeringPolicy size="100MB"/>
            Policies>
        RollingFile>
    appenders>
    
    <loggers>
        
        <logger name="org.springframework" level="INFO">logger>
        <logger name="org.mybatis" level="INFO">logger>
        <root level="all">
            <appender-ref ref="Console"/>
            <appender-ref ref="RollingFileInfo"/>
            <appender-ref ref="RollingFileWarn"/>
            <appender-ref ref="RollingFileError"/>
        root>
    loggers>
configuration>

你可能感兴趣的:(spring)