Disable Java Log Rotation

I use java.util.logging.Logger to enter my application:

    FileHandler fh=new FileHandler(this.todayFileName, 0, 1, true);

    fh.setFormatter(new SimpleFormatter());

    Logger.getLogger(rootLogger.getName()).setLevel(Level.ALL);

    Logger.getLogger(rootLogger.getName()).addHandler(fh); 

but this works well, except that log rotation is enabled.

and I get the files:

run.log run.log.1 run.log.2

I want to get only one log file without rotation enabled.

how to do it?

+3
source share
4 answers

If you run the same application at the same time, java.util.logging will create many log files, such as run.log run.log.1 run.log.2

And you are sure that your application closes correctly, because I already have this problem. Since my application did not close correctly when I started the application that created the myApplication.log file.

+1

FileHandle. tht , , .

, .

+1

, . (, - ..), . , , . . , , , (, - ), . , , , , . , , - , ...

/ , , .

+1

, Integer.MAX_INT 0. 0 0 , , , .

, " , ", 1-arg, , .

-1

Source: https://habr.com/ru/post/1719081/


All Articles