1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

log4j2 で 出力をバッファリングするには immediateFlush 設定が必要

Posted at

log4j2 で 出力をバッファリングするには immediateFlush 設定が必要

log4j2 で、 bufferedIO="true" (そもそもtrueがデフォルト)にしても出力がバッファリングされないので悩んでいたら、
immediateFlush="false" も設定しないと、各ログ毎にフラッシュされてしまうことに気づいた。

よって、ログ出力をバッファリングするには、 immediateFlush="false" も設定しないと駄目

例:

log4j2.xml
    <Appenders>
        <RollingFile name="Name" fileName="/var/log/hoge.log" filePattern="/var/log/hoge.log.%i.gz" immediateFlush="false">
            <PatternLayout pattern="%d{yyyy-MM-dd'T'HH:mm:ssZ} %m%n"/>
            <Policies>
                <SizeBasedTriggeringPolicy size="100MB"/>
            </Policies>
            <DefaultRolloverStrategy max="10" fileIndex="min"/>
        </RollingFile>
    </Appenders>

参考

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?