Repository: cxf
Updated Branches:
  refs/heads/3.1.x-fixes 0b5f511f0 -> 1c8f4298a


[CXF-7389] Logging ClientErrorExceptions with FINE level, making it possible to 
customize it


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/1c8f4298
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/1c8f4298
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/1c8f4298

Branch: refs/heads/3.1.x-fixes
Commit: 1c8f4298a1c2ee28c04865cb64f4066c2d0495b1
Parents: 0b5f511
Author: Sergey Beryozkin <[email protected]>
Authored: Thu Aug 31 13:39:30 2017 +0100
Committer: Sergey Beryozkin <[email protected]>
Committed: Thu Aug 31 13:44:30 2017 +0100

----------------------------------------------------------------------
 .../org/apache/cxf/jaxrs/utils/JAXRSUtils.java  | 23 +++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/1c8f4298/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
----------------------------------------------------------------------
diff --git 
a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java 
b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
index 7fdb82c..27b0d8f 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
@@ -46,6 +46,7 @@ import java.util.TreeMap;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
+import javax.ws.rs.ClientErrorException;
 import javax.ws.rs.Consumes;
 import javax.ws.rs.HttpMethod;
 import javax.ws.rs.Produces;
@@ -527,7 +528,8 @@ public final class JAXRSUtils {
                                                    
mediaTypeToString(requestType),
                                                    
convertTypesToString(acceptContentTypes));
         if (!"OPTIONS".equalsIgnoreCase(httpMethod)) {
-            LOG.warning(errorMsg.toString());
+            Level logLevel = getExceptionLogLevel(message, 
ClientErrorException.class);
+            LOG.log(logLevel == null ? Level.FINE : logLevel, 
errorMsg.toString());
         }
         Response response = 
             createResponse(getRootResources(message), message, 
errorMsg.toString(), status, methodMatched == 0);
@@ -535,6 +537,25 @@ public final class JAXRSUtils {
         
     }    
 
+    
+    
+    private static Level getExceptionLogLevel(Message message, Class<? extends 
WebApplicationException> exClass) {
+        Level logLevel = null;
+        Object logLevelProp = message.get(exClass.getName() + ".log.level");
+        if (logLevelProp != null) {
+            if (logLevelProp instanceof Level) {
+                logLevel = (Level)logLevelProp;
+            } else {
+                try {
+                    logLevel = Level.parse(logLevelProp.toString());
+                } catch (Exception ex) {
+                    // ignore
+                }
+            }
+        }
+        return logLevel;
+    }
+
     private static List<MediaType> intersectSortMediaTypes(List<MediaType> 
acceptTypes,
                                                            List<MediaType> 
producesTypes,
                                                            final boolean 
checkDistance) {

Reply via email to