As Tomcat internally uses JUL to log , you can use the system property java.util.logging.config.file
to specify the file path of the properties file. For the format of this properties file , you can refer to your JRE_HOME/lib/logging.properties
(which is the default configuration file used by JUL)
However, JUL does not support the daily rotation . If you don't mind , you can use its java.util.logging.FileHandler
to rotate the log files based on the log 's file size instead:
# Define the FileHandler
handlers= java.util.logging.FileHandler
# Configure the FileHandler
java.util.logging.FileHandler.pattern = %h/java%u.log
java.util.logging.FileHandler.limit = 1024000
java.util.logging.FileHandler.count = 3
java.util.logging.FileHandler.formatter = java.util.logging.SimpleFormatter
java.util.logging.FileHandler.append=true
Then , each log file will has the limit size 1024000 bytes (1MB) , and maximum roll to 3 output log files . You can refer the Javadoc of java.util.logging.FileHandler for the details about the configuration.
You have to implemnt the File Handler if you want to support rotation on daily basis using JUL . I found a custom implemenation from this blog . I did not try it yet. You can refer it if you have any interest.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…