简体   繁体   English

如何从部署在同一tomcat中的另一个war文件重新配置war文件的log4j

[英]How to reconfigure log4j of a war file from another war file deployed in same tomcat

I have two war files WARA and WARB deployed in a tomcat, both use same log4j properties file. 我在tomcat中部署了两个war文件WARA和WARB,它们都使用相同的log4j属性文件。 How to reset the log4j configurations in both war files through another stand alone application deployed in same tomcat without disturbing WARA and WARB? 如何通过部署在同一雄猫中的另一个独立应用程序重置两个war文件中的log4j配置,而又不影响WARA和WARB? Is it possible to do? 有可能吗?

If polling is an option you can use PropertyConfigurator.configureAndWatch() . 如果可以选择轮询,则可以使用PropertyConfigurator.configureAndWatch()

More here . 这里更多。

If you need to do it manually the process is bit longer. 如果您需要手动执行此过程,则过程会更长一些。 On a high level its as follows. 在高层次上,其如下。

  1. Configure JMX for your application server / servlet container. 为您的应用程序服务器/ Servlet容器配置JMX。
  2. Write an MBean to trigger full reconfiguration. 编写一个MBean来触发完全重新配置。
  3. Register the MBean in WARA and WARB. 在WARA和WARB中注册MBean。
  4. Connect to the MBean server from the other webapp. 从另一个Web应用程序连接到MBean服务器。
  5. Invoke the MBean in WARA and WARB. 在WARA和WARB中调用MBean。

If you can provide more details on what software stack your are using I may be able to provide specific details on how to do the above. 如果您可以提供有关正在使用的软件堆栈的更多详细信息,我也许可以提供有关如何执行上述操作的特定详细信息。

不是最好的方法,而是制作一个包含属性文件的jar文件,并将其放置在tomcat lib文件夹中,所有应用程序都使用相同的propertyfiles。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM