码迷,mamicode.com
首页 > 编程语言 > 详细

log4j2 自定义配置文件,java载入

时间:2017-02-23 18:28:28      阅读:308      评论:0      收藏:0      [点我收藏+]

标签:example   log4j2   html   sep   file   man   manage   path   spec   

http://logging.apache.org/log4j/2.x/faq.html#separate_log_files

How do I reconfigure log4j2 in code with a specific configuration file?

 

See the below example. Be aware that this LoggerContext class is not part of the public API so your code may break with any minor release.

  1. // import org.apache.logging.log4j.core.LoggerContext;
  2.  
  3. LoggerContext context = (org.apache.logging.log4j.core.LoggerContext) LogManager.getContext(false);
  4. File file = new File("path/to/a/different/log4j2.xml");
  5.  
  6. // this will force a reconfiguration
  7. context.setConfigLocation(file.toURI());

log4j2 自定义配置文件,java载入

标签:example   log4j2   html   sep   file   man   manage   path   spec   

原文地址:http://www.cnblogs.com/bigben0123/p/6434671.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!