问题描述
这似乎不是一个有效的问题,但是我在这里有要求.以下是我的项目结构:
common (built as a jar) module-1 (war, includes common.jar in its classpath) module-2 (war, includes common.jar in its classpath) module-3 (war, includes common.jar in its classpath) module-4 (war, includes common.jar in its classpath)
部署如下:
模块-1和模块2在一台服务器上,模块-3和模块-4在另一个服务器上.
要求是拥有两个单独的日志文件(每个服务器一个).因此,实现此目的的方法是将log4j.properties(绝对带有不同名称)放在公共模块中,然后将所需属性文件复制到相应的服务器的Conf文件夹.
我不确定,如果我可以拥有带有不同名称的记录属性文件,如果可能的话,请帮助我提供一个方向.
编辑使它更容易,如果您都可以告诉我我是否可以使用log4j.properties文件的其他名称以及如何将其加载到服务器,我将能够实现其余的.
谢谢.
推荐答案
我终于解决了这个问题,是的,有一种方法与log4j配置属性文件使用不同的名称.
我们可以说什么我们想说mylog4j.properties.为了使JVM拾取此内容,我们需要将论点转到下面的JVM:
:-Dlog4j.configuration=mylog4j.properties
使用Eclipse运行应用程序时,您可以通过运行配置 - >参数选项卡 - > VM参数来完成此操作并添加属性 -Dlog4j.configuration=mylog4j.properties
问题描述
This might not seem a valid question but I have a requirement here. Below is my project structure:
common (built as a jar) module-1 (war, includes common.jar in its classpath) module-2 (war, includes common.jar in its classpath) module-3 (war, includes common.jar in its classpath) module-4 (war, includes common.jar in its classpath)
The deployment is like below:
module-1 and module-2 is on one server and module-3 and module-4 on another.
The requirement is to have two separate log files(one for each server). So, the way to achieve this is put the log4j.properties (definitely with different names) in the common module and copy the required properties file to the respective server's conf folder.
I am not sure, if I can have the logging properties file with different names, if it is possible, please help me with a direction to do so.
EDIT To make this easier, if you anyone can tell me if I can use a different name for the log4j.properties file and how to load it to the server, I would be able to achieve the rest.
Thanks.
推荐答案
I finally fixed this issue, and yes there is a way of using a name different than log4j.properties for the log4j configuration properties file.
We can name it whatever we want say mylog4j.properties. For the JVM to pick this up we need to pass an argument to the JVM like below:
-Dlog4j.configuration=mylog4j.properties
When running applications using eclipse, you can do this by going to Run Configurations -> Arguments Tab -> VM Arguments and add the property -Dlog4j.configuration=mylog4j.properties