EclipseLink and log4j: how to use both

I use the Eclipselink JPA provider, and noticed that it only writes in the console. I have configured both console and file applications, but EclipseLink log entries (such as SQL queries) appear only in the console log. How to fix it?

Here is my log4j configuration:

log4j.rootLogger=ALL, FILE, CONSOLE log4j.logger.uk.co.mycompany=DEBUG log4j.logger.org.eclipse.persistence=ALL log4j.appender.FILE=org.apache.log4j.DailyRollingFileAppender log4j.appender.FILE.File=${catalina.base}/logs/application.log log4j.appender.FILE.layout=org.apache.log4j.PatternLayout log4j.appender.FILE.layout.ConversionPattern=%d{HH:mm:ss, SSS} %t [%p] %c{1} - %m%n # CONSOLE is set to be a ConsoleAppender using a PatternLayout. log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout log4j.appender.CONSOLE.layout.ConversionPattern=%d{HH:mm:ss,SSS} [%p] %m%ne 

In the persistence.xml file:

 ... <properties> <property name="eclipselink.logging.level" value="FINE"/> </properties> 
+6
source share
4 answers

Eclipse Link does not use log4j by default. This page describes how you can integrate it:

http://wiki.eclipse.org/EclipseLink/Foundation/Logging

+4
source

Make sure that you initialize the EclipseLink logging tools (by performing some of the actions that usually require logging) before adding your own handlers to the system. I think that EclipseLink overrides the settings of the root registrar and possibly destroys your configuration.

0
source

If you use EclipseLink with JBoss AS7, I recommend Step 5: Set up EclipseLink logging (optional) on the next page on how to log correctly:

https://community.jboss.org/wiki/HowToUseEclipseLinkWithAS7

In short, you will need:

  • Add the JBossLogger.java file to the project (attached to the article)
  • Add jboss-logging library dependency
  • Set the eclipselink.logging.logger property to persistence.xml
0
source

Source: https://habr.com/ru/post/900542/


All Articles