Uploaded image for project: 'CXF'
  1. CXF
  2. CXF-1981

Inconsistent use of logger delegation via LogUtils

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.2
    • Fix Version/s: 2.0.10, 2.1.4
    • Component/s: None
    • Labels:
      None

      Description

      Even after installation of Log4jLogger delegate (via META-INF/cxf/org.apache.cxf.Logger file) some messages still are logged by java.util.logging – example:

      14 Jan 2009 14:09:05,358 [ContainerBackgroundProcessor[StandardEngine[Catalina]]] INFO org.apache.cxf.bus.spring.BusApplicationContext - Refreshing org.apache.cxf.bus.spring.BusApplicationContext@6c826c82: display name [org.apache.cxf.bus.spring.BusApplicationContext@6c826c82]; startup date [Wed Jan 14 14:09:05 CET 2009]; parent: org.springframework.web.context.support.XmlWebApplicationContext@6abe6abe
      14 Jan 2009 14:09:05,393 [ContainerBackgroundProcessor[StandardEngine[Catalina]]] INFO org.apache.cxf.bus.spring.BusApplicationContext - Bean factory for application context [org.apache.cxf.bus.spring.BusApplicationContext@6c826c82]: org.springframework.beans.factory.support.DefaultListableBeanFactory@75d275d2
      ...
      Jan 14, 2009 2:10:03 PM org.apache.cxf.phase.PhaseInterceptorChain doIntercept
      INFO: Application has thrown exception, unwinding now
      org.apache.cxf.interceptor.Fault
      at org.apache.cxf.service.invoker.AbstractInvoker.createFault(AbstractInvoker.java:148)
      at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:114)
      ...

      Review of PhaseInterceptorChain class shows that some log messages are passed via delegating logger and other via direct call to LogUtils:

      public class PhaseInterceptorChain implements InterceptorChain {
      private static final Logger LOG = LogUtils.getL7dLogger(PhaseInterceptorChain.class);
      ...
      public void add(Interceptor i, boolean force) {
      ...
      if (LOG.isLoggable(Level.FINE))

      { LOG.fine("Adding interceptor " + i + " to phase " + phaseName); }

      ...
      }

      public synchronized boolean doIntercept(Message message) {
      ...
      if (LOG.isLoggable(Level.FINE))

      { LogUtils.log(LOG, Level.FINE, "Application has thrown exception, unwinding now", ex); }

      else if (LOG.isLoggable(Level.INFO))

      { ... }

      }

      Workaround is to install SFL4J delegating JUL to Log4j however I guess it would be better clean up the code. I think that use of LogUtils.log() should be forbidden and enforcement could be done via checkstyle (marking this method as depreciaded first) or introduction of AOP with aspect checking calls to illegal method.

      cheers,
      andy

        Attachments

          Activity

            People

            • Assignee:
              seanoc Sean O'Callaghan
              Reporter:
              amichalec Andrzej Michalec
            • Votes:
              1 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: