log4j in EAP 6.4

Latest response

I am deploying seam 2.2 application in EAP 6.4. In EAP 6, logging dependencies for common third-party frameworks like Apache log4j and SLF4J are added by default. Is it possible to use default log4j library? If yes, how to config log4j properties?

It is described in the document that I need exclude third party logging framework dependencies and then add log4j library into application level for using a log4j.properties or log4j.xml file. Can I just copy log4j jar file from EAP 6 default module? Or I have to download apache log4j library.

Responses

You can use either but it's best to use the one that is shipped in JBoss.

If I use embedded Apache log4j in JBoss, how can I specify log4j configuration? Can you show me a simple example?

Hi Terry

Did you search our Knowledge Base?

We have a number of articles based around logging JBoss depending on what you want to do. See https://access.redhat.com/solutions/17852, https://access.redhat.com/solutions/105653, or https://access.redhat.com/solutions/19767 as examples.

Mus

I resolved the issue following this article - https://access.redhat.com/solutions/105653. The workaround is that I packaged a copy of log4j.jar in my application along with Log4J configuration file.

In my opinion it is definitely not better as a customer to use the log4j (or slf4j) embedded in JBoss EAP. For better or worse, logging is not part of the JEE specification and using a vendor-specific container-provided logging provider is not standard practice. It might be better for RedHat to have you more locked in to their solution.

A more forward looking and standard solution for EAP 6.3 and above than the one referenced in https://access.redhat.com/solutions/105653, is to set a system property "add-logging-api-dependencies" to false as described in this KB article:

https://access.redhat.com/solutions/1202633 "Disable implicit logging dependencies in EAP 6 "

Then JBoss EAP acts like other containers with respect to log4j, slf4j, etc.

Regards,

Scott