log4j2配置详解



<Configuration status="off" monitorInterval="1800">
    <properties>
        
        <property name="LOG_HOME">/WEB-INF/logsproperty>
        
        <property name="LOG_ROOT">${web:rootDir}property>
        
        <property name="FILE_NAME">ubsproperty>
    properties>
    <Appenders>
        
        
        
        

        
        <Console name="Console" target="SYSTEM_OUT">
            
            <ThresholdFilter level="DEBUG" onMatch="ACCEPT" onMismatch="DENY" />
            
            <PatternLayout pattern="%d{HH:mm:ss.SSS} %-5level %class{36} %L %M - %msg%xEx%n" />
            
        Console>
        
        <Console name="console_err" target="SYSTEM_ERR">
            <ThresholdFilter level="ERROR" onMatch="ACCEPT" onMismatch="DENY" />
            <PatternLayout pattern="%5p [%t] %d{yyyy-MM-dd HH:mm:ss} (%F:%L) %m%n" />
        Console>
        
        <RollingFile name="trace_appender" immediateFlush="true" fileName="${LOG_HOME}/trace.log" filePattern="${LOG_HOME}/trace/trace - %d{yyyy-MM-dd HH_mm_ss}.log.gz">
            <PatternLayout>
                <pattern>%5p [%t] %d{yyyy-MM-dd HH:mm:ss} (%F:%L) %m%npattern>
            PatternLayout>
            <Policies>
                
                <SizeBasedTriggeringPolicy size="2MB" />
            Policies>
            <Filters>
                
                <ThresholdFilter level="debug" onMatch="DENY" onMismatch="NEUTRAL" />
                <ThresholdFilter level="trace" onMatch="ACCEPT" onMismatch="DENY" />
            Filters>
        RollingFile>
        
        <RollingFile name="debug_appender" immediateFlush="true" fileName="${LOG_HOME}/debug.log" filePattern="${LOG_HOME}/debug/debug - %d{yyyy-MM-dd HH_mm_ss}.log.gz">
            <PatternLayout>
                <pattern>%5p [%t] %d{yyyy-MM-dd HH:mm:ss} (%F:%L) %m%npattern>
            PatternLayout>
            <Policies>
                
                <SizeBasedTriggeringPolicy size="2MB" />
                
                <TimeBasedTriggeringPolicy interval="1" modulate="true" />
            Policies>
            <Filters>
                
                <ThresholdFilter level="info" onMatch="DENY" onMismatch="NEUTRAL" />
                <ThresholdFilter level="debug" onMatch="ACCEPT" onMismatch="DENY" />
            Filters>
        RollingFile>
        
        <RollingFile name="info_appender" immediateFlush="true" fileName="${LOG_HOME}/info.log" filePattern="${LOG_HOME}/info/info - %d{yyyy-MM-dd HH_mm_ss}.log.gz">
            <PatternLayout>
                <pattern>%5p [%t] %d{yyyy-MM-dd HH:mm:ss} (%F:%L) %m%npattern>
            PatternLayout>
            <Policies>
                <SizeBasedTriggeringPolicy size="2MB" />
            Policies>
            <Filters>
                <ThresholdFilter level="warn" onMatch="DENY" onMismatch="NEUTRAL" />
                <ThresholdFilter level="info" onMatch="ACCEPT" onMismatch="DENY" />
            Filters>
        RollingFile>
        
        <RollingFile name="warn_appender" immediateFlush="true" fileName="${LOG_HOME}/warn.log" filePattern="${LOG_HOME}/warn/warn - %d{yyyy-MM-dd HH_mm_ss}.log.gz">
            <PatternLayout>
                <pattern>%5p [%t] %d{yyyy-MM-dd HH:mm:ss} (%F:%L) %m%npattern>
            PatternLayout>
            <Policies>
                <SizeBasedTriggeringPolicy size="2MB" />
            Policies>
            <Filters>
                <ThresholdFilter level="error" onMatch="DENY" onMismatch="NEUTRAL" />
                <ThresholdFilter level="warn" onMatch="ACCEPT" onMismatch="DENY" />
            Filters>
        RollingFile>
        
        <RollingFile name="error_appender" immediateFlush="true" fileName="${LOG_HOME}/error.log" filePattern="${LOG_HOME}/error/error - %d{yyyy-MM-dd HH_mm_ss}.log.gz">
            <PatternLayout>
                <pattern>%5p [%t] %d{yyyy-MM-dd HH:mm:ss} (%F:%L) %m%npattern>
            PatternLayout>
            <Policies>
                <SizeBasedTriggeringPolicy size="2MB" />
            Policies>
            <Filters>
                <ThresholdFilter level="error" onMatch="ACCEPT" onMismatch="DENY" />
            Filters>
        RollingFile>
        <File name="info" fileName="${web:rootDir}/../../ubslogs/ubsinfo.log" append="true">
            <Filters>
                <ThresholdFilter level="WARN" onMatch="DENY" onMismatch="NEUTRAL" />
                <ThresholdFilter level="info" onMatch="ACCEPT" onMismatch="DENY" />
            Filters>
            <PatternLayout pattern="%d{yyyy.MM.dd HH:mm:ss z} %-5level %class{36} %L %M - %msg%xEx%n" />
        File>
        <File name="error" fileName="${web:rootDir}/../../ubslogs/ubserror.log" append="true">
            <Filters>
                <ThresholdFilter level="error" onMatch="ACCEPT" onMismatch="DENY" />
            Filters>
            <PatternLayout pattern="%d{yyyy.MM.dd HH:mm:ss z} %-5level %class{36} %L %M - %msg%xEx%n" />
        File>
    Appenders>
    <Loggers>
        
        
        <Root level="trace" additivity="false">
            
            <AppenderRef ref="Console"/>
            <AppenderRef ref="console_err"/>
            
            <AppenderRef ref="trace_appender"/>
            <AppenderRef ref="debug_appender"/>
            <AppenderRef ref="info_appender"/>
            <AppenderRef ref="warn_appender"/>
            <AppenderRef ref="error_appender"/>

            <AppenderRef ref="info"/>
            <AppenderRef ref="error"/>
        Root>
    Loggers>
Configuration>

你可能感兴趣的:(log4j,前端,c++)