Help us understand the problem. What is going on with this article?

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

More than 1 year has passed since last update.

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>

参考

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした