转载:
Changing the log level is simple; modifying other portions of the configuration will pose a more in depth approach. The changes are permanent through the life cyle of the UPDATE: If you are using Log4j 2 you should remove the calls to
| |||||||||||||||||||||
|
up vote 66 down vote | File Watchdog Log4j is able to watch the Caution: configureAndWatch method is unsafe for use in J2EE environments due to a Thread leak JMXAnother way to set the log level (or reconfiguring in general) log4j is by using JMX. Log4j registers its loggers as JMX MBeans. Using the application servers MBeanServer consoles (or JDK') you can reconfigure each individual loggers. These changes are not persistent and would be reset to the config as set in the configuration file after you restart your application (server). Self-Made As described by Aaron, you can set the log level programmatically. You can implement it in your application in the way you would like it to happen. For example, you could have a GUI where the user or admin changes the log level and then call the
| ||||||||||||||||||||
|
up vote 2 down vote | Log4j2 can be configured to refresh its configuration by scanning l file (or equivalent) at given intervals. Just add the "monitorInterval" parameter to your configuration tag. See line 2 of the l file, which tells log4j to to re-scan its configuration if more than 5 seconds have passed since the last log event.
| ||||
|
up vote 1 down vote | With log4j 1.x I find the best way is to use a DOMConfigurator to submit one of a predefined set of XML log configurations (say, one for normal use and one for debugging). Making use of these can be done with something like this: Just call this with the appropriate config name, and make sure that you put the templates on the classpath.
| ||||||||||||||||||||
|
up vote 0 down vote | I did this to dynamically Change log4j log level and it worked for me, I have n't referred any document. I used this system property value to set my logfile name. I used the same technique to set logging level as well, and it worked passed this as JVM parameter (I use Java 1.7) in the log4j.properties file, I added this entry I tried It all worked. hope this helps! I have these following dependencies in l
| ||||
|
本文发布于:2024-02-02 08:04:48,感谢您对本站的认可!
本文链接:https://www.4u4v.net/it/170683228942467.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
留言与评论(共有 0 条评论) |