我正在EC2上运行后台应用程序,并以Logback作为记录器。我无法将私有IP(或公共IP或主机名)地址添加到每行的开头。我的logback.xml如下:
<?xml version="1.0"?>
<configuration>
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
<file>log_root.log</file>
<append>true</append>
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%-8.8thread] %-5level %msg%n</pattern>
</encoder>
</appender>
<appender name="HEARTBEAT-RECD-FILE" class="ch.qos.logback.core.FileAppender">
<file>log_heartbeat_recd.log</file>
<append>true</append>
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%-8.8thread] %-5level %msg%n</pattern>
</encoder>
</appender>
<logger name="heartbeat_recd" level="OFF" additivity="false">
<appender-ref ref="HEARTBEAT-RECD-FILE"/>
</logger>
<root>
<appender-ref ref="FILE"/>
</root>
</configuration>