`
lushuaiyin
  • 浏览: 673406 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

log4j.properties的放置位置

 
阅读更多

今天和项目经理讨论了下log4j.properties具体的放置位置,我开始赞成直接放置在classpath下面,这样方便管理,对性能应该也有所提高,但经理从服务器管理者的角度告诉我这种做法的缺陷:更新log4j.properties时必然要重启应用,灵活性会降低。比如我要将输出控制由INFO 到 DEBUG 如果能配置到外面则方便很多。他还说了如果要重启某个应用需要重启多个服务器,因为做了集群,但我认为这个是危言耸听,做集群能没有同步么。

总结:

1.log4j.properties放置在classpath下面。

优点:方便管理,节省资源。

缺点:灵活性差。

2.log4j.properties放置在外部。

有点:灵活性高。

缺点:需要建立相关的文档、相对浪费资源。

如何配置在外面:

Java代码

  1. publicLoggerm_log=null;

  2. publicETrafficPlanService(){

  3. PropertyConfigurator.configure("data//config//log4j//log4j_etraffic.properties");

  4. m_log=Logger.getLogger(ETrafficPlanService.class);

  5. m_log.debug("debugtest...........");

  6. }

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics