You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by dk...@apache.org on 2011/07/25 20:23:11 UTC
svn commit: r1150823 - in /cxf/branches/2.4.x-fixes: ./
common/common/src/main/java/org/apache/cxf/common/logging/Slf4jLogger.java
Author: dkulp
Date: Mon Jul 25 18:23:10 2011
New Revision: 1150823
URL: http://svn.apache.org/viewvc?rev=1150823&view=rev
Log:
Merged revisions 1150820 via svnmerge from
https://svn.apache.org/repos/asf/cxf/trunk
........
r1150820 | dkulp | 2011-07-25 14:20:20 -0400 (Mon, 25 Jul 2011) | 2 lines
[CXF-3680] Logging locations are hidden with Slf4jLogger
Patch from Woonsan Ko applied
........
Modified:
cxf/branches/2.4.x-fixes/ (props changed)
cxf/branches/2.4.x-fixes/common/common/src/main/java/org/apache/cxf/common/logging/Slf4jLogger.java
Propchange: cxf/branches/2.4.x-fixes/
('svn:mergeinfo' removed)
Propchange: cxf/branches/2.4.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.
Modified: cxf/branches/2.4.x-fixes/common/common/src/main/java/org/apache/cxf/common/logging/Slf4jLogger.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.4.x-fixes/common/common/src/main/java/org/apache/cxf/common/logging/Slf4jLogger.java?rev=1150823&r1=1150822&r2=1150823&view=diff
==============================================================================
--- cxf/branches/2.4.x-fixes/common/common/src/main/java/org/apache/cxf/common/logging/Slf4jLogger.java (original)
+++ cxf/branches/2.4.x-fixes/common/common/src/main/java/org/apache/cxf/common/logging/Slf4jLogger.java Mon Jul 25 18:23:10 2011
@@ -21,6 +21,8 @@ package org.apache.cxf.common.logging;
import java.util.logging.Level;
import java.util.logging.LogRecord;
+import org.slf4j.spi.LocationAwareLogger;
+
/**
* <p>
* java.util.logging.Logger implementation delegating to SLF4J.
@@ -46,11 +48,17 @@ import java.util.logging.LogRecord;
*/
public class Slf4jLogger extends AbstractDelegatingLogger {
+ private static final String FQCN = AbstractDelegatingLogger.class.getName();
+
private final org.slf4j.Logger logger;
+ private LocationAwareLogger locationAwareLogger;
public Slf4jLogger(String name, String resourceBundleName) {
super(name, resourceBundleName);
logger = org.slf4j.LoggerFactory.getLogger(name);
+ if (logger instanceof LocationAwareLogger) {
+ locationAwareLogger = (LocationAwareLogger) logger;
+ }
}
@Override
@@ -85,23 +93,55 @@ public class Slf4jLogger extends Abstrac
* comparisons is important. We first try log level FINE then INFO, WARN, FINER, etc
*/
if (Level.FINE.equals(level)) {
- logger.debug(msg, t);
+ if (locationAwareLogger == null) {
+ logger.debug(msg, t);
+ } else {
+ locationAwareLogger.log(null, FQCN, LocationAwareLogger.DEBUG_INT, msg, null, t);
+ }
} else if (Level.INFO.equals(level)) {
- logger.info(msg, t);
+ if (locationAwareLogger == null) {
+ logger.info(msg, t);
+ } else {
+ locationAwareLogger.log(null, FQCN, LocationAwareLogger.INFO_INT, msg, null, t);
+ }
} else if (Level.WARNING.equals(level)) {
- logger.warn(msg, t);
+ if (locationAwareLogger == null) {
+ logger.warn(msg, t);
+ } else {
+ locationAwareLogger.log(null, FQCN, LocationAwareLogger.WARN_INT, msg, null, t);
+ }
} else if (Level.FINER.equals(level)) {
- logger.trace(msg, t);
+ if (locationAwareLogger == null) {
+ logger.trace(msg, t);
+ } else {
+ locationAwareLogger.log(null, FQCN, LocationAwareLogger.TRACE_INT, msg, null, t);
+ }
} else if (Level.FINEST.equals(level)) {
- logger.trace(msg, t);
+ if (locationAwareLogger == null) {
+ logger.trace(msg, t);
+ } else {
+ locationAwareLogger.log(null, FQCN, LocationAwareLogger.TRACE_INT, msg, null, t);
+ }
} else if (Level.ALL.equals(level)) {
// should never occur, all is used to configure java.util.logging
// but not accessible by the API Logger.xxx() API
- logger.error(msg, t);
+ if (locationAwareLogger == null) {
+ logger.error(msg, t);
+ } else {
+ locationAwareLogger.log(null, FQCN, LocationAwareLogger.ERROR_INT, msg, null, t);
+ }
} else if (Level.SEVERE.equals(level)) {
- logger.error(msg, t);
+ if (locationAwareLogger == null) {
+ logger.error(msg, t);
+ } else {
+ locationAwareLogger.log(null, FQCN, LocationAwareLogger.ERROR_INT, msg, null, t);
+ }
} else if (Level.CONFIG.equals(level)) {
- logger.debug(msg, t);
+ if (locationAwareLogger == null) {
+ logger.debug(msg, t);
+ } else {
+ locationAwareLogger.log(null, FQCN, LocationAwareLogger.DEBUG_INT, msg, null, t);
+ }
} else if (Level.OFF.equals(level)) {
// don't log
}