Log file locking issues in Batch scripting
I have a batch file which starts a Java server class. The output of the Java is redirected to a log file. This batch file is stared via a windows service. Problem is this log file is becoming very huge. Since the Java server is running, it is not possible to do any modification in the Log file as it is locked. How can I create a new log file for every day?
My idea was to write another batch file which will stop the service, backup the existing log file, delete and start the 开发者_JAVA百科service file again. Is this approach correct?
java -Xms32m -Xmx256m gtServer >> abclog.txt
Above is the code in the batch file which starts the sever
Any tips on how we could back up the file without stopping the java server?
Thanks in advance
Karthik
Heard about log4j?
Ok, seriously, would it be possible to use some proper logging facility? It usually provides something for this purpose like RollingFileAppender.
精彩评论