[英]How to change log4j2 logging path on tomcat?
I'm running a webapp on tomcat
using spring-boot
. 我正在使用
spring-boot
在tomcat
上运行一个webapp。
How could I change the log4j2.xml
logging path dynamically? 如何动态更改
log4j2.xml
日志记录路径? (eg by jvm args, property file, or else)? (例如通过jvm args,属性文件或其他)?
So far I configured the log xml as follows: 到目前为止,我将日志xml配置如下:
<Configuration>
<Properties>
<property name="path">${bundle:application:log.path}</property>
</Properties>
</Configuration>
With configuration file: 带有配置文件:
#application.properties:
log.path=d:/
Now I want to dynamically force the logpath to eg d:/log-test
, but without having to modify my war
file. 现在,我想动态地将
d:/log-test
路径强制为d:/log-test
,而不必修改我的war
文件。 Because on redeployment I would lose any manual configuration. 因为重新部署后,我将失去任何手动配置。
So how could I provide a different logging path? 那么我如何提供不同的日志记录路径?
I want to run multiple profiles on the same machine, so environment or system properties are of no use for me here. 我想在同一台机器上运行多个配置文件,因此这里的环境或系统属性对我没有用。
As has already been suggested using ${sys:LOG_PATH} is probably the best solution. 正如已经建议的那样,使用$ {sys:LOG_PATH}可能是最好的解决方案。 You do not have to modify the war, but you do have to run a tomcat for dev and a separate tomcat for test.
您不必修改战争,但必须为开发人员运行一个tomcat,为测试运行一个单独的tomcat。 Then just place set CATALINA_OPTS to include -DLOG_PATH=/my/log/path in setenv.sh or setenv.bat It really wouldn't make a lot of sense to have a single tomcat running both anyway.
然后将set CATALINA_OPTS设置为在setenv.sh或setenv.bat中包含-DLOG_PATH = / my / log / path,无论如何,要同时运行两个tomcat确实没有多大意义。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.