I'm developing a tool to monitor logging files of several application, those applications use either java.logging or Log4j.
The appender is always a rolling file appender with the size of the file as trigger for the rolling. When a rolling happens for both ( java.logging and log4j ) all logging files are renamed to allow the current logging file to have the same name.
My problem is if i'm currently reading the logging file i'm keeping it from being renamed and therefore it will be erase because the logger will not append on a file it should have just created.
I tried to use a socketAppender to avoid reading on a file and directly gathering the data, but the action of logging takes at least 0,1ms (0,02 with a fileAppender) and as i have a granularity of 1ms for one of my application i can't use this.
I obtained those result by changing the configuration of my loggers and using this code
long start=System.currentTimeMillis();
long numberOfLog=0;
long total=1000000;
while(numberOfLog<total){
log.info(" "+numberOfLog);
numberOfLog++;
}
long duree=System.currentTimeMillis()-start;
System.out.println("la durée est de "+duree+"ms pour "+total+" logs");
Now i'm wondering is there any solution to read those logging file without interfering with the rename ? Or is there a solution to configure those tools ( log4j, java.logging ) to roll on a size trigger and whithout renaming the files (using date for the name or other solutions) ?
Thank you for your feedback