admin管理员组

文章数量:1431720

I'm using Log4j - 2.22.1. version and wildfly- 31.0.1.Final Loggers are printing in local But, while deploying it on openshift the loggers are not printing after the ear is deployed and i checked the logs that printed before deployment and i found a error like this

 ERROR [stderr] (MSC service thread 1-3) ERROR StatusLogger Log4j2 could not find a logging implementation. Please add log4j-core to the classpath. Using SimpleLogger to log to the console...

this are the dependencies using

implementation '.apache.logging.log4j:log4j-core:2.22.1'
implementation '.apache.logging.log4j:log4j-api:2.22.1'

Tried Adding this Dependency to the lib but didn't worked

implementation '.apache.logging.log4j:log4j-to-slf4j:2.21.1'

Tried adding log4j2.xml

<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN">
    <Appenders>
        <Console name="Console" target="SYSTEM_OUT">
            <PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss} %-5p [%c{1}] %m%n"/>
        </Console> <File name="File" fileName="logs/app.log">
        <PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss} %-5p [%c{1}] %m%n"/>
    </File>
    </Appenders>
    <Loggers>
        <Root level="info">
            <AppenderRef ref="Console"/>
            <AppenderRef ref="File"/>
        </Root>
        <Logger name=".jboss" level="info" additivity="false">
            <AppenderRef ref="Console"/>
            <AppenderRef ref="File"/>
        </Logger>
    </Loggers>
</Configuration>

and excluded wildfly logging subsystem in jboss-deployment but didn't worked

<exclude-subsystems>
  <subsystem name="logging"/>
</exclude-subsystems>

I'm using Log4j - 2.22.1. version and wildfly- 31.0.1.Final Loggers are printing in local But, while deploying it on openshift the loggers are not printing after the ear is deployed and i checked the logs that printed before deployment and i found a error like this

 ERROR [stderr] (MSC service thread 1-3) ERROR StatusLogger Log4j2 could not find a logging implementation. Please add log4j-core to the classpath. Using SimpleLogger to log to the console...

this are the dependencies using

implementation '.apache.logging.log4j:log4j-core:2.22.1'
implementation '.apache.logging.log4j:log4j-api:2.22.1'

Tried Adding this Dependency to the lib but didn't worked

implementation '.apache.logging.log4j:log4j-to-slf4j:2.21.1'

Tried adding log4j2.xml

<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN">
    <Appenders>
        <Console name="Console" target="SYSTEM_OUT">
            <PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss} %-5p [%c{1}] %m%n"/>
        </Console> <File name="File" fileName="logs/app.log">
        <PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss} %-5p [%c{1}] %m%n"/>
    </File>
    </Appenders>
    <Loggers>
        <Root level="info">
            <AppenderRef ref="Console"/>
            <AppenderRef ref="File"/>
        </Root>
        <Logger name=".jboss" level="info" additivity="false">
            <AppenderRef ref="Console"/>
            <AppenderRef ref="File"/>
        </Logger>
    </Loggers>
</Configuration>

and excluded wildfly logging subsystem in jboss-deployment but didn't worked

<exclude-subsystems>
  <subsystem name="logging"/>
</exclude-subsystems>
Share Improve this question edited Nov 20, 2024 at 6:40 Paul asked Nov 19, 2024 at 8:18 PaulPaul 113 bronze badges 9
  • Have you checked your deployment to make sure it's including the log4j-core library? Also, is there a reason you need to use the log4j configuration? The same configuration would work in the logging subsystem. Then you wouldn't need to use log4j-core, just the log4j-api. – James R. Perkins Commented Nov 20, 2024 at 17:47
  • Yeah now i added only the log4j-api and checked in deployment also still in openshift loggers are not printing – Paul Commented Nov 21, 2024 at 8:57
  • You shouldn't even need to add the API to your deployment. WildFly contains a module for the API. You'd need to make sure you remove the jboss-deployment-structure.xml as well. – James R. Perkins Commented Nov 21, 2024 at 20:41
  • Tried that one too still same error – Paul Commented Nov 27, 2024 at 10:11
  • I'm not too sure what the issue would be. What version of JBoss EAP are you using? – James R. Perkins Commented Nov 27, 2024 at 16:19
 |  Show 4 more comments

1 Answer 1

Reset to default 0

Upgrade from log4j2 to slf4j-2.x fixed the issue

本文标签: loggingLoggers are not printing on OpenShift Console after deploymentStack Overflow