Discussion:
[jira] [Created] (LOG4J2-444) Log4j2 eclipselink integration
Hemri (JIRA)
2013-11-07 17:15:18 UTC
Permalink
Hemri created LOG4J2-444:
----------------------------

Summary: Log4j2 eclipselink integration
Key: LOG4J2-444
URL: https://issues.apache.org/jira/browse/LOG4J2-444
Project: Log4j 2
Issue Type: Question
Affects Versions: 2.0-beta9
Reporter: Hemri


Hi everyone,

I wanted to know If someone knows a way to integrate eclipselink logger with log4j2. I try to do it myself but I didn't succeed.

Thanks !



--
This message was sent by Atlassian JIRA
(v6.1#6144)
Matt Sicker (JIRA)
2014-01-05 08:22:50 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-444?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13862515#comment-13862515 ]

Matt Sicker commented on LOG4J2-444:
------------------------------------

Isn't EclipseLink just a JPA implementation? There's already the JPAApender unless that doesn't work with EL for some reason.
Post by Hemri (JIRA)
Log4j2 eclipselink integration
------------------------------
Key: LOG4J2-444
URL: https://issues.apache.org/jira/browse/LOG4J2-444
Project: Log4j 2
Issue Type: Question
Affects Versions: 2.0-beta9
Reporter: Hemri
Hi everyone,
I wanted to know If someone knows a way to integrate eclipselink logger with log4j2. I try to do it myself but I didn't succeed.
Thanks !
--
This message was sent by Atlassian JIRA
(v6.1.5#6160)
Matt Sicker (JIRA)
2014-01-07 03:01:57 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-444?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13863863#comment-13863863 ]

Matt Sicker commented on LOG4J2-444:
------------------------------------

Alright, looks like this would actually be rather simple. We've only got the org.eclipse.persistence.jpa dependency as an API dependency. You still need to provide a JPA provider to use it. As a matter of fact, all the unit tests for the JPAAppender et al. classes use EclipseLink, so I can assure you that you can use it.
Post by Hemri (JIRA)
Log4j2 eclipselink integration
------------------------------
Key: LOG4J2-444
URL: https://issues.apache.org/jira/browse/LOG4J2-444
Project: Log4j 2
Issue Type: Question
Affects Versions: 2.0-beta9
Reporter: Hemri
Hi everyone,
I wanted to know If someone knows a way to integrate eclipselink logger with log4j2. I try to do it myself but I didn't succeed.
Thanks !
--
This message was sent by Atlassian JIRA
(v6.1.5#6160)
Nick Williams (JIRA)
2014-01-29 06:30:10 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-444?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13885059#comment-13885059 ]

Nick Williams commented on LOG4J2-444:
--------------------------------------

Hemri, it occurred to me that you could mean one of two things. Do you:

A) Want to write your logs to a database using EclipseLink as a JPA implementation? Or,
B) Want EclipseLink's internal logging statements to go through your Log4j configuration?
Post by Hemri (JIRA)
Log4j2 eclipselink integration
------------------------------
Key: LOG4J2-444
URL: https://issues.apache.org/jira/browse/LOG4J2-444
Project: Log4j 2
Issue Type: Question
Affects Versions: 2.0-beta9
Reporter: Hemri
Hi everyone,
I wanted to know If someone knows a way to integrate eclipselink logger with log4j2. I try to do it myself but I didn't succeed.
Thanks !
--
This message was sent by Atlassian JIRA
(v6.1.5#6160)
Hemri (JIRA)
2014-01-29 12:52:09 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-444?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13885304#comment-13885304 ]

Hemri commented on LOG4J2-444:
------------------------------

Hi,

I want to EclipseLink's internal logging statements go through Log4j2.
I handle this on my side with the following:

in persistence.xml:
<property name="eclipselink.logging.logger" value="com.mycompany.project.CustomJPALogger"/>

And the custom class:
public class CustomJPALogger extends AbstractSessionLog implements SessionLog {
private static final Logger LOGGER = LoggerFactory.getLogger(CustomJPALogger.class);

@Override
public void log(SessionLogEntry entry) {
int level = entry.getLevel();
String message = entry.getMessage();
if (entry.getParameters() != null) {
message += " [";
int index = 0;
for (Object object : entry.getParameters()) {
message += (index++ > 0 ? "," : "") + object;
}
message += "]";
}
switch (level) {
case SessionLog.SEVERE:
LOGGER.error(message);
break;
case SessionLog.WARNING:
LOGGER.warn(message);
break;
case SessionLog.INFO:
LOGGER.info(message);
break;
case SessionLog.CONFIG:
LOGGER.trace(message);
break;
default:
LOGGER.debug(message);
break;
}
}
}

I know it's not a very elegant solution, but it works.
Don't you know a best way to achieve this?

Thanks
Post by Hemri (JIRA)
Log4j2 eclipselink integration
------------------------------
Key: LOG4J2-444
URL: https://issues.apache.org/jira/browse/LOG4J2-444
Project: Log4j 2
Issue Type: Question
Affects Versions: 2.0-beta9
Reporter: Hemri
Hi everyone,
I wanted to know If someone knows a way to integrate eclipselink logger with log4j2. I try to do it myself but I didn't succeed.
Thanks !
--
This message was sent by Atlassian JIRA
(v6.1.5#6160)
Hemri (JIRA)
2014-01-29 12:52:12 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-444?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13885304#comment-13885304 ]

Hemri edited comment on LOG4J2-444 at 1/29/14 12:52 PM:
--------------------------------------------------------

Hi,

I want to EclipseLink's internal logging statements go through Log4j2.
I handle this on my side with the following:

in persistence.xml:
{code:borderStyle=solid}
<property name="eclipselink.logging.logger" value="com.mycompany.project.CustomJPALogger"/>
{code}

And the custom class:
{code:borderStyle=solid}
public class CustomJPALogger extends AbstractSessionLog implements SessionLog {
private static final Logger LOGGER = LoggerFactory.getLogger(CustomJPALogger.class);

@Override
public void log(SessionLogEntry entry) {
int level = entry.getLevel();
String message = entry.getMessage();
if (entry.getParameters() != null) {
message += " [";
int index = 0;
for (Object object : entry.getParameters()) {
message += (index++ > 0 ? "," : "") + object;
}
message += "]";
}
switch (level) {
case SessionLog.SEVERE:
LOGGER.error(message);
break;
case SessionLog.WARNING:
LOGGER.warn(message);
break;
case SessionLog.INFO:
LOGGER.info(message);
break;
case SessionLog.CONFIG:
LOGGER.trace(message);
break;
default:
LOGGER.debug(message);
break;
}
}
}
{code}
I know it's not a very elegant solution, but it works.
Don't you know a best way to achieve this?

Thanks


was (Author: draiwn):
Hi,

I want to EclipseLink's internal logging statements go through Log4j2.
I handle this on my side with the following:

in persistence.xml:
<property name="eclipselink.logging.logger" value="com.mycompany.project.CustomJPALogger"/>

And the custom class:
public class CustomJPALogger extends AbstractSessionLog implements SessionLog {
private static final Logger LOGGER = LoggerFactory.getLogger(CustomJPALogger.class);

@Override
public void log(SessionLogEntry entry) {
int level = entry.getLevel();
String message = entry.getMessage();
if (entry.getParameters() != null) {
message += " [";
int index = 0;
for (Object object : entry.getParameters()) {
message += (index++ > 0 ? "," : "") + object;
}
message += "]";
}
switch (level) {
case SessionLog.SEVERE:
LOGGER.error(message);
break;
case SessionLog.WARNING:
LOGGER.warn(message);
break;
case SessionLog.INFO:
LOGGER.info(message);
break;
case SessionLog.CONFIG:
LOGGER.trace(message);
break;
default:
LOGGER.debug(message);
break;
}
}
}

I know it's not a very elegant solution, but it works.
Don't you know a best way to achieve this?

Thanks
Post by Hemri (JIRA)
Log4j2 eclipselink integration
------------------------------
Key: LOG4J2-444
URL: https://issues.apache.org/jira/browse/LOG4J2-444
Project: Log4j 2
Issue Type: Question
Affects Versions: 2.0-beta9
Reporter: Hemri
Hi everyone,
I wanted to know If someone knows a way to integrate eclipselink logger with log4j2. I try to do it myself but I didn't succeed.
Thanks !
--
This message was sent by Atlassian JIRA
(v6.1.5#6160)
Nick Williams (JIRA)
2014-02-08 03:18:19 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-444?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Nick Williams resolved LOG4J2-444.
----------------------------------

Resolution: Not A Problem
Assignee: Nick Williams

According to the [EclipseLink logging documentation|http://wiki.eclipse.org/EclipseLink/Foundation/Logging#Using_Log4J], you just need to make sure Commons Logging 1.1.x and the Log4j 2 Commons Logging Bridge (Maven artifact log4j-jcl) are on your classpath and add the following property to your persistence unit:

{code:xml}<property name="eclipselink.logging.logger" value="org.eclipse.persistence.logging.CommonsLoggingSessionLog"/>{code}
Post by Hemri (JIRA)
Log4j2 eclipselink integration
------------------------------
Key: LOG4J2-444
URL: https://issues.apache.org/jira/browse/LOG4J2-444
Project: Log4j 2
Issue Type: Question
Affects Versions: 2.0-beta9
Reporter: Mickael Hemri
Assignee: Nick Williams
Hi everyone,
I wanted to know If someone knows a way to integrate eclipselink logger with log4j2. I try to do it myself but I didn't succeed.
Thanks !
--
This message was sent by Atlassian JIRA
(v6.1.5#6160)

Loading...