How to add a files in the class path of the Provider jar

Hi folks,
I have created a provider jar for catching event in Keycloak. I would like to write logs using log4j2.xml. I added log4j2.xml file under Resource/META-INF folder. After I deployed the jar in Keycloak I’m getting an error saying “ERROR StatusLogger No log4j2 configuration file found.” Attaching my project structure

image

Do I need to specify log4j2.xml somewhere else? Can anyone help me?

1 Like

Hi,
I’ve found this topic java - Jboss logging to slf4j/log4j2 with Keycloak - Stack Overflow . The interresting part is :

Wildfly logging dependencies are excluded by setting add-logging-api-dependencies to false . log4j2.xml is specified outside the packaged EAR and is referenced with log4j.configurationFile system property.

I’ve put the log4j2.xml in the /opt/jboss/keycloak/standalone/configuration folder , used log4j2.configurationFile property instead of .log4j.configurationFile
and tried to set the log4j2.configurationFile by many means :

  • LOG4J_CONFIGURATION_FILE env variable
  • JAVA_OPT env variable : -Dlog4j2.configurationFile=/opt/jboss/keycloak/standalone/configuration/log4j2.xml
  • using jboss.cli : /system-property=log4j2.configurationFile:add(value=${env.JBOSS_HOME}/standalone/configuration/log4j2.xml)

BTW, I didn’t succeed to make it work so far and still have the " ERROR StatusLogger No log4j2 configuration file found" .

But may be it can give you some clues to solve your situation.

Regards,

Finally, I changed to a log4j2.xml included in my provider jar as you did and it works now.
My issue was that I previously managed the log4j2 dependencies as external modules (through a jboss-deployment-structure.xml).
It looks like the log4j2.configurationFile property is not properly handled .

Regards,

Too much hope !
I falled into the following issue : https://issues.apache.org/jira/browse/LOG4J2-954 about incompatibility between maven assembly plugin and the way log4j2 is loading its configuration files .

I’ll continue to investigate and keep this thread up to date of the progress.

Regards,