两次运行同一jar时出现Log4j问题

时间:2018-08-02 05:29:12

标签: java log4j

我的系统中同时运行一个可执行jar,侦听两个不同的接口套接字

java -ip <port-1-IP> -jar executable.jar 
java -ip <port-2-IP> -jar executable.jar 

log4j附加程序配置如下

<appender name="workflow" class="org.apache.log4j.RollingFileAppender">
    <param name="append" value="true" />
    <param name="maxFileSize" value="50MB" />
    <param name="file" value="/var/log/public_access_workflow.log" />
    <layout class="org.apache.log4j.PatternLayout">
        <param name="ConversionPattern" value="%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n" />
    </layout>
    <param name="MaxBackupIndex" value="5" />
</appender>
<appender name="workflow_csv" class="org.apache.log4j.RollingFileAppender">
    <param name="append" value="true" />
    <param name="maxFileSize" value="50MB" />
    <param name="file" value="/var/log/public_access_workflow_csv.log" />
    <layout class="org.apache.log4j.PatternLayout">
        <param name="ConversionPattern" value="%m%n" />
    </layout>
    <param name="MaxBackupIndex" value="5" />
</appender>
<appender name="workflow_comms" class="org.apache.log4j.RollingFileAppender">
    <param name="append" value="true" />
    <param name="maxFileSize" value="50MB" />
    <param name="file" value="/var/log/public_access_workflow_comms.log" />
    <layout class="org.apache.log4j.PatternLayout">
        <param name="ConversionPattern" value="%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n" />
    </layout>
    <param name="MaxBackupIndex" value="5" />
</appender>

在运行时或启动时是否可以更改log4j文件?

编辑: 使用Linux和Jetty服务器(org.eclipse.jetty.server.Server)和org.apache.log4j.Logger

0 个答案:

没有答案