log4j日志配置






<configuration status="warn" monitorInterval="30">

    <properties>
        <property name="logPath">/applog/wimiplus_rec/logsproperty>
        <property name="PATTERN_LAYOUT">%d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %-5p %c{1}:%L - %enc{%msg}{CRLF}%nproperty>
    properties>

    
    <appenders>
        
        <console name="Console" target="SYSTEM_OUT">
            
            
            <PatternLayout pattern="${PATTERN_LAYOUT}"/>
        console>

        
        <RollingFile name="StartLog" fileName="${logPath}/Start.log"
                     filePattern="${logPath}/Start-%d{yyyy-MM-dd}-%i.log">
            <PatternLayout pattern="${PATTERN_LAYOUT}"/>
            <Policies>
                <TimeBasedTriggeringPolicy/>
                <SizeBasedTriggeringPolicy size="100 MB"/>
            Policies>

            
            <DefaultRolloverStrategy max="20">
                
                <Delete basePath="${logPath}" maxDepth="2">
                    <IfFileName glob="start-*.log"/>
                    <IfLastModified age="7d"/>
                Delete>
            DefaultRolloverStrategy>
        RollingFile>

        
        <RollingFile name="RollingFileInfo" fileName="${logPath}/root.log"
                      filePattern="${logPath}/info-%d{yyyy-MM-dd}-%i.log">
            <Filters>
                <MarkerFilter marker = "operation_log" onMatch="DENY" onMismatch="NEUTRAL"/>
                
                <ThresholdFilter level="INFO" onMatch="ACCEPT" onMismatch="DENY"/>
                <ThresholdFilter level="WARN" onMatch="DENY" onMismatch="NEUTRAL"/>
            Filters>
            <PatternLayout pattern="${PATTERN_LAYOUT}"/>
            
            <Policies>
                <TimeBasedTriggeringPolicy/>
                <SizeBasedTriggeringPolicy size="100 MB"/>
            Policies>

            
            <DefaultRolloverStrategy max="20">
                
                <Delete basePath="${logPath}" maxDepth="2">
                    <IfFileName glob="root-*.log"/>
                    <IfLastModified age="7d"/>
                Delete>
            DefaultRolloverStrategy>
        RollingFile>

        
        <RollingFile name="RollingFileWarn" fileName="${logPath}/warn.log"
                     filePattern="${logPath}/warn-%d{yyyy-MM-dd}-%i.log">
            <Filters>
                <ThresholdFilter level="WARN" onMatch="ACCEPT" onMismatch="DENY"/>
                <ThresholdFilter level="ERROR" onMatch="DENY" onMismatch="NEUTRAL"/>
            Filters>
            <PatternLayout pattern="${PATTERN_LAYOUT}"/>
            <Policies>
                <TimeBasedTriggeringPolicy/>
                <SizeBasedTriggeringPolicy size="100 MB"/>
            Policies>

            
            <DefaultRolloverStrategy max="20">
                <Delete basePath="${logPath}" maxDepth="2">
                    <IfFileName glob="warn-*.log"/>
                    <IfLastModified age="7d"/>
                Delete>
            DefaultRolloverStrategy>
        RollingFile>

        
        <RollingFile name="RollingFileError" fileName="${logPath}/error.log"
                     filePattern="${logPath}/error-%d{yyyy-MM-dd}-%i.log">
            <ThresholdFilter level="ERROR"/>
            <PatternLayout pattern="${PATTERN_LAYOUT}" />
            <Policies>
                <TimeBasedTriggeringPolicy/>
                <SizeBasedTriggeringPolicy size="100 MB"/>
            Policies>

            
            <DefaultRolloverStrategy max="20">
                <Delete basePath="${logPath}" maxDepth="2">
                    <IfFileName glob="error-*.log"/>
                    <IfLastModified age="7d"/>
                Delete>
            DefaultRolloverStrategy>
        RollingFile>

        
        <RollingFile name="RollingFileSql" filename="${logPath}/sql.log"
                     filepattern="${logPath}/sql-%d{yyyyMMdd}-%i.log">
            <PatternLayout pattern="${PATTERN_LAYOUT}" />
            <Policies>
                <TimeBasedTriggeringPolicy/>
                <SizeBasedTriggeringPolicy size="100 MB"/>
            Policies>
        RollingFile>

        
        <RollingFile name="RollingFileOperation" fileName="${logPath}/operation-hdsf.log"
                     filePattern="${logPath}/operation-hdsf-%d{yyyy-MM-dd}-%i.log">
            <Filters>
                <MarkerFilter marker = "operation_log" onMatch="ACCEPT" onMismatch="DENY"/>
                <ThresholdFilter level="INFO" onMatch="ACCEPT" onMismatch="DENY"/>
                <ThresholdFilter level="WARN" onMatch="DENY" onMismatch="NEUTRAL"/>
            Filters>
            <PatternLayout pattern="${PATTERN_LAYOUT}" />
            <Policies>
                <TimeBasedTriggeringPolicy/>
                <SizeBasedTriggeringPolicy size="100 MB"/>
            Policies>

            <DefaultRolloverStrategy max="20">
                <Delete basePath="${logPath}" maxDepth="2">
                    <IfFileName glob="operation-hdsf-*.log"/>
                    <IfLastModified age="7d"/>
                Delete>
            DefaultRolloverStrategy>
        RollingFile>
    appenders>

    
    <loggers>
        
        
        <logger name="org.hibernate.type.descriptor.sql.BasicBinder" level="DEBUG"  />
        <logger name="org.hibernate.SQL" level="DEBUG" />
        <logger name="org.hibernate.engine.spi.QueryParameters" level="DEBUG" />

        <root level="INFO">
            <appender-ref ref="Console"/>
            <appender-ref ref="RollingFileInfo"/>
            <appender-ref ref="RollingFileWarn"/>
            <appender-ref ref="RollingFileError"/>
            <appender-ref ref="StartLog"/>
            <appender-ref ref="RollingFileOperation"/>
        root>
    loggers>

configuration>

你可能感兴趣的:(log4j,java,服务器)