Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
3.2k views
in Technique[技术] by (71.8m points)

代码如下log4j的日志,已经设置了最大10m,为什么生产了文件还是50m?

<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="debug">
    <Properties>
        <property name="log_pattern">%d{yyyy-MM-dd HH:mm:ss z} %-5level %class{36} %L %M - %msg%xEx%n</property>
        <property name="file_name">/home/chat/chatClient/chatClient.log</property>
        <property name="rolling_file_name">/home/chat/chatClient/chatClient-%d{yyyy-MM-dd}-%i.log.gz</property>
        <property name="every_file_size">10M</property><!-- 日志切割的最小单位 -->
        <property name="output_log_level">info</property><!-- 日志输出级别 -->
    </Properties>
    <Appenders>
        <Console name="console" target="SYSTEM_OUT">
            <!--控制台只输出level及以上级别的信息(onMatch),其他的直接拒绝(onMismatch)-->
            <ThresholdFilter level="info" onMatch="ACCEPT" onMismatch="DENY"/>
            <!--这个都知道是输出日志的格式-->
            <PatternLayout pattern="${log_pattern}"/>
        </Console>
    
        <RollingFile name="RollingFile" fileName="${file_name}" filePattern="${rolling_file_name}">
            <PatternLayout pattern="${log_pattern}"/>
            <SizeBasedTriggeringPolicy size="${every_file_size}"/>
            <Filters>
                <ThresholdFilter level="info" onMatch="ACCEPT" onMismatch="DENY"/>
            </Filters>  
        </RollingFile>
    </Appenders>
    <Loggers>
        <root level="${output_log_level}">
            <appender-ref ref="RollingFile"/>
             <appender-ref ref="console"/>
        </root>
    </Loggers>
</Configuration>

image


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神解答

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...