Tech Per

30 Jan

Configuring CXF Logging To Go Through Log4J

Apparently, CXF has chosen the JSE logging API as their API against logging. But you can make CXF log through Log4J quite easily. In the org.apache.cxf.common.logging package of the CXF apidocs, I found the Log4JLogger class, which is a specialization of the JSE logging api java.util.logging.Logger class, delegating logging to a Log4J implementation.

Configuring Log4J in CXF

In the same package as Log4JLogger, I also found the LogUtils class, which CXF uses to obtain logger instances from. This class also contains a static final string KEY, which is set to the value org.apache.cxf.Logger. CXF uses this value, to bootstrap which logging API to use.

You can either put a META-INF/cxf/org.apache.cxf.Logger file onto the classpath with the org.apache.cxf.common.logging.Log4jLogger class name in it as a single line, or you can supply a -Dorg.apache.cxf.Logger=org.apache.cxf.common.logging.Log4jLogger system property to your code, when executing.

2 Responses to “Configuring CXF Logging To Go Through Log4J”

  1. 1
    Tech Per » Blog Archive » Viewing Inbound and Outbound Messages in CXF Says:

    […] messages through its logging API. As a standard, the logging API in CXF is JDK logging, but you can configure CXF to use Log4J logging instead. You will need to ensure, that at least INFO level logging has been enabled for these […]

  2. 2
    Tech Per » Blog Archive » Making CXF Log RuntimeExceptions From Server Implementations Says:

    […] mentioned in my post on how to configure log4j as logging engine in cxf, cxf comes out of the box with JavaSE logging (java.util.logging) as its logging engine. If you […]

Leave a Reply

© 2008 Tech Per | Entries (RSS) and Comments (RSS)

GPS Reviews and news from GPS Gazettewordpress logo