1

ファイルサイズが制限サイズを超えたため、java.util.logging.FileHandler.limitプロパティに問題があります。ここでは、アプリケーションでプロパティが使用されています

java.util.logging.FileHandler.pattern = ATMChannelAdapter%u.log
java.util.logging.FileHandler.limit = 2000000
java.util.logging.FileHandler.count = 10
java.util.logging.FileHandler.formatter = java.util.logging.SimpleFormatter

それは正常に動作し、ある時点で、アプリケーションは構成ファイルのサイズを超えて制限なしで1つのファイルにのみ書き込み、約1 GBのリッチになり、通常の構成に戻るにはアプリケーションを再起動する必要があります.

オペレーティング システムは Windows Server 2012 Java 7 です。

誰かが同様の問題を抱えていますか?これは高負荷で発生する可能性がありますか?

前もって感謝します

4

1 に答える 1

0

何かが LogManager のプロパティをリセットしているか、java.util.logging.FileHandler の整数オーバーフローが原因でファイルのローテーションが妨げられています。回転を妨げる条件を調べる次のフォーマッターをインストールしてみてください。

public class FileSimpleFormatter extends SimpleFormatter {

    private static final Field METER;
    private static final Field COUNT;

    static {
        try {
            METER = FileHandler.class.getDeclaredField("meter");
            METER.setAccessible(true);

            COUNT = FileHandler.class.getDeclaredField("count");
            COUNT.setAccessible(true);
        } catch (RuntimeException re) {
            throw re;
        } catch (Exception e) {
            throw new ExceptionInInitializerError(e);
        }
    }

    private volatile FileHandler h;

    @Override
    public String getHead(Handler h) {
        this.h = FileHandler.class.cast(h);
        return super.getHead(h);
    }

    private String check() {
        FileHandler target = h;
        if (target != null) {
            try {
                Object os = METER.get(target);
                if (os != null && os.getClass().getName().endsWith("MeteredStream")) {
                    Field written = os.getClass().getDeclaredField("written");
                    written.setAccessible(true);
                    Number c = Number.class.cast(COUNT.get(target));
                    Number w = Number.class.cast(written.get(os));
                    if (c.intValue() <= 0 || w.intValue() < 0) {
                        return String.format("target=%1$s count=%2$s written=%3$s%n",
                                target, c, w);
                    }
                }
            } catch (IllegalAccessException ex) {
                throw (Error) new IllegalAccessError(ex.getMessage()).initCause(ex);
            } catch (NoSuchFieldException ex) {
                throw (Error) new NoSuchFieldError(ex.getMessage()).initCause(ex);
            }
        }
        return "";
    }

    @Override
    public String format(LogRecord record) {
        return super.format(record).concat(check());
    }
}

次に、ログ ファイルを検索して、何か見つかったかどうかを確認します。

更新: Oracle はJDK-8059767 の下でこの問題に取り組んでいます。FileHandler は「長い」制限を許可し、MeteredStream.written のオーバーフローを処理する必要があります。

于 2014-09-08T14:12:01.290 に答える