I am currently trying to configure logging in JBoss 6 and looking at the different alternatives. My requirements are:
1) Automatic reload of any log configuration changes without application re-deployment.
2) Multiple log files one for each log level. E.g. one myApp-error.log that logs only error messages, myApp-debug.log that logs only debug messages, etc. This means being able to set minimum and maximum levels for each of the appenders/handlers set for each file.
Now, I know I can use the jboss-logging.xml file which is shipped with JBoss 6 AS. I do get automatic reload by using this file as it takes advantage of the hot deployment feature in JBoss (this file is located in t开发者_如何学Gohe deploy directory).
However, I can't get to configure my log to set a maximum level for each of the handlers. I can set a minimum level, but that means that e.g. my debug file will get debug and all levels above. Not what I need.
Other option would be using an external configuration file. E.g. log4j.xml. This can be achieved by setting a system property as stated here. Good since I can use a org.apache.log4j.varia.LevelRangeFilter filter to limit the maximum and minimum log levels. However this doesn't allow for automatic reload of logging configuration without re-deploying the application.
Is there any chance I can get both requirements using JBoss 6 AS whether with the shipped logging system or with an external one?
1) About automatic reload.:
You should be able to periodically check log4j.xml file for change and if it change, than call org.apache.log4j.xml.DOMConfigurator.configure("<path to log4j.xml>").
精彩评论