Reputation: 11
I use log4j2 on a springboot web application with microservices deployed on openshift 3.11. below the configuration of log4j2
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="${env:LOGGING_LEVEL}">
<Properties>
<Property name="log_path">/home/jboss/logs</Property>
</Properties>
<Appenders>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout pattern="%d{dd-MM-yyyy HH:mm:ss.SSS} %green{[${hostName}]} %magenta{[%thread]} %highlight{%-5level} %logger{36}.%M - %msg%n" />
</Console>
<RollingFile name="fileLogger" fileName="${log_path}/application.log" filePattern="${log_path}/application.%i.log.zip" filePermissions="rw-rw-r-" >
<PatternLayout pattern="%d{dd-MM-yyyy HH:mm:ss.SSS} [${hostName}] [%thread] %-5level%logger{36}.%M - %msg%n" />
<Policies>
<SizeBasedTriggeringPolicy size="200MB" />
</Policies>
<DefaultRolloverStrategy max="30"/>
</RollingFile>
</Appenders>
<Loggers>
<Root level="INFO">
<AppenderRef ref="Console" level="${env:LOGGING_LEVEL}"/>
<AppenderRef ref="fileLogger" level="${env:LOGGING_LEVEL}"/>
</Root>
</Loggers>
</Configuration>
my problem is as follows: multiple pods should write to the log file at the same time, on the first application.log file there are no problems but when the rolling occurs and the application.log file becomes application.1.log.zip the application.log file is written by a single pod and the same thing happens at subsequent rolling, is there a configuration that allows all pods to write the same file avoiding the situation described?
Upvotes: 1
Views: 947
Reputation: 1
Writing multiple pods/nodes log4j logs to a single file is not a best practice or a good idea, as this creates an ambiguity problem for updating logs.
Upvotes: 0