Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

EclipseLink and log4j: how to use both

I'm using Eclipselink JPA provider, and noticed that it writes in console only. I configured both the console and file appenders, but EclipseLink log entries (SQL queries for example) are appeared 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:

...
    <properties>
        <property name="eclipselink.logging.level" value="FINE"/>           
    </properties>
like image 951
javagirl Avatar asked Nov 01 '11 17:11

javagirl


1 Answers

Eclipse Link doesn't use log4j by default. This page describes how you can integrate it:

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

like image 197
orien Avatar answered Sep 18 '22 13:09

orien