tomcat - Java Logger not rotating log files -
i'm using tomcat 8.0.21 on rhel 7. in java code i'm logging text file java.util.logging.logger
.
there 1 log file. if restart tomcat logging starts again moment , previous logs gone.
i added %g
file name instructed here adds 0 file name , no rotation occurs.
here code create filehandler
. strfilepath
value example "/tmp/mylog.log". logformatter
own class.
// need set format own formatter class plain text 1 line (default format xml). filehandler file_handler = new filehandler(strfilepath); file_handler.setformatter(new logformatter()); logger.addhandler(file_handler);
on windows 7 laptop logs rotate fine using same code , tomcat version.
how can enable java logger
log file rotation on rhel server?
edit: guess add timestamp file name when constructing filehandler
. i'm going try that.
the filehandler rotates when limit exceeded (or unable lock file). if want rotate files time have code that. if want trigger rotation create throw away file handler limit of 0 bytes before open actual file handler.
new filehandler(pattern, 0, 1, false).close();
Comments
Post a Comment