Java FileHandler disable log rotation

折月煮酒 提交于 2019-12-04 06:29:40

问题


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.


回答1:


Try 0 as the limit instead of 1000000.




回答2:


Handler fileHandler = new FileHandler(FILE_PATH, true);



回答3:


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



来源:https://stackoverflow.com/questions/914457/java-filehandler-disable-log-rotation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!