Java FileHandler disable log rotation

2019-03-04 11:48发布

I am trying to disable log rotation, for file handler using,

FileHandler fh = new FileHandler
    ( "path" + "run.log", 1000000, 1, false);

What i want is one log, created for each run i do not want rotation or backing up of the old file, but using this initialization i get run.log run.log.1 run.log.2 for each run.

Also

        logger.setUseParentHandlers(false);

is set to false.

3条回答
霸刀☆藐视天下
2楼-- · 2019-03-04 12:02
Handler fileHandler = new FileHandler(FILE_PATH, true);
查看更多
三岁会撩人
3楼-- · 2019-03-04 12:07

Try 0 as the limit instead of 1000000.

查看更多
干净又极端
4楼-- · 2019-03-04 12:13

Try this: FileHandler fh = new FileHandler( "path" + "run.log", 1000000, 1, true);

查看更多
登录 后发表回答