I have an application with below log4j2.xml file embedded within the project. Logging is working fine in my local setup and also in this particular Linux server ( CPE OS Name: cpe:/o:redhat:enterprise_linux:7.9:GA:server ). However when we testing in this particular Linux server (CPE OS Name: cpe:/o:redhat:enterprise_linux:9::baseos) logs are not getting written in mentioned path. I have doublechecked with the permission issue & folder creation and I don't see any issue in that.
Log4j2.xml
<?xml version="1.0" encoding="UTF-8"?>
<Configuration>
<Properties>
<Property name="base_log">/com/logs/testing/</Property>
<Property name="testing_utility_log">${base_log}/testing_utility.log</Property>
</Properties>
<Appenders>
<RollingFile name="testing_utility" fileName="${testing_utility_log}" filePattern="${testing_utility_log}_%d{dd-MM-yyyy}" ignoreExceptions="false">
<PatternLayout>
<Pattern>%d{HH:mm:ss,SSS}[%t] %-5p(%F:%L) - %m%n</Pattern>
</PatternLayout>
<TimeBasedTriggeringPolicy/>
</RollingFile>
</Appenders>
<Loggers>
<Root level="INFO">
<AppenderRef ref="testing_utility"/>
</Root>
</Loggers>
</Configuration>
and below dependency jars in the classpath.
commons-codec-1.16.1.jar
commons-io-2.15.1.jar
commons-lang3-3.12.0.jar
log4j-api-2.17.2.jar
log4j-core-2.17.2.jar
log4j-jul-2.17.2.jar
log4j-slf4j-impl-2.17.2.jar
slf4j-api-1.7.31.jar
In the code , I have this below logging related details
import .apache.logging.log4j.LogManager;
import .apache.logging.log4j.Logger;
private static final Logger LOGGER = LogManager.getLogger(Testing.class);
LOGGER.info("[Starting Testing for {} ] ", fileName);
**/// Local log trace**
09:52:33,349[main] INFO (Testing.java:39) - [Starting Testing for TEST45678 ]
I have an application with below log4j2.xml file embedded within the project. Logging is working fine in my local setup and also in this particular Linux server ( CPE OS Name: cpe:/o:redhat:enterprise_linux:7.9:GA:server ). However when we testing in this particular Linux server (CPE OS Name: cpe:/o:redhat:enterprise_linux:9::baseos) logs are not getting written in mentioned path. I have doublechecked with the permission issue & folder creation and I don't see any issue in that.
Log4j2.xml
<?xml version="1.0" encoding="UTF-8"?>
<Configuration>
<Properties>
<Property name="base_log">/com/logs/testing/</Property>
<Property name="testing_utility_log">${base_log}/testing_utility.log</Property>
</Properties>
<Appenders>
<RollingFile name="testing_utility" fileName="${testing_utility_log}" filePattern="${testing_utility_log}_%d{dd-MM-yyyy}" ignoreExceptions="false">
<PatternLayout>
<Pattern>%d{HH:mm:ss,SSS}[%t] %-5p(%F:%L) - %m%n</Pattern>
</PatternLayout>
<TimeBasedTriggeringPolicy/>
</RollingFile>
</Appenders>
<Loggers>
<Root level="INFO">
<AppenderRef ref="testing_utility"/>
</Root>
</Loggers>
</Configuration>
and below dependency jars in the classpath.
commons-codec-1.16.1.jar
commons-io-2.15.1.jar
commons-lang3-3.12.0.jar
log4j-api-2.17.2.jar
log4j-core-2.17.2.jar
log4j-jul-2.17.2.jar
log4j-slf4j-impl-2.17.2.jar
slf4j-api-1.7.31.jar
In the code , I have this below logging related details
import .apache.logging.log4j.LogManager;
import .apache.logging.log4j.Logger;
private static final Logger LOGGER = LogManager.getLogger(Testing.class);
LOGGER.info("[Starting Testing for {} ] ", fileName);
**/// Local log trace**
09:52:33,349[main] INFO (Testing.java:39) - [Starting Testing for TEST45678 ]
Share
Improve this question
edited Mar 3 at 6:35
Chennai Cheetah
asked Mar 3 at 6:06
Chennai CheetahChennai Cheetah
3631 silver badge15 bronze badges
3
|
2 Answers
Reset to default 1Have you checked whether SELinux is affecting log writing? In RHEL 9, the Enforcing mode is enabled by default, which may restrict access to files even if standard permissions are set correctly. To verify if SELinux is causing the issue, you can temporarily disable it with:
sudo setenforce 0
This command temporarily switches SELinux to Permissive mode, where security checks are still performed but do not block operations and are only logged.
It is working now. I removed log4j2.xml from the project and instead added log4j2ponent.properties and pointed log4j2.xml path value in it.
log4j2ponent.properties
log4j.configurationFile=/com/logs/test/log4j2.xml
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745107903a4611668.html
-Dlog4j2.debug
? The diagnostic output will be onstderr
. – Piotr P. Karwasz Commented Mar 3 at 14:48