You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cxf.apache.org by Diego Delgado Roda <di...@eurecat.org> on 2016/06/20 15:46:29 UTC

Apache CXF log separation

Hello,

I'll try to explain my situation as well as I can. given that I have little experience in Apache CXF in particular and in web application programming in general.

I built and deployed a JAX-RS REST API as a WAR into my WSO2 Application Server (WSO2 AS). This WSO2 AS runs an Apache CXF 2.7.6 environment which contains the needed dependencies to run my REST API.
Under WSO2 AS this CXF is configured to send log messages to Log4j framework. This can be verified in the following message of the WSO2 AS server startup log:

12:32:55.087 [localhost-startStop-1] DEBUG org.apache.cxf.common.logging.LogUtils[<clinit>:140] - Using org.apache.cxf.common.logging.Log4jLogger for logging.

The problem arises when I want to use the SLF4J / Logback framework to log my REST API. The achieve that I put the needed dependencies under WEB-INF/lib.
During the server startup one thing changes, the CXF framework now detects my SLF4J / logback framework and sends its log messages to my appenders configured in WEB-INF/classes/logback.xml. Again, this can be verified in the following message of the WSO2 AS server startup log:

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [bundleresource://460.fwk1889868818:1/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/C:/Users/Diego/wso2as-5.2.1/repository/deployment/server/webapps/MYAPP_JAX-RS_1.0.0/WEB-INF/lib/logback-classic-1.1.3.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [ch.qos.logback.classic.util.ContextSelectorStaticBinder]
22:01:13.232 [localhost-startStop-1] DEBUG org.apache.cxf.common.logging.LogUtils[<clinit>:140] - Using org.apache.cxf.common.logging.Slf4jLogger for logging.

The problem is that now my logback appenders are mixed with org.apache.cxf DEBUG log messages and my REST API log messages. So the purpose of isolate my REST API logs are not possible using this SLF4J / Logback approach.

My question is if it's possible to make WEB-INF/lib only visible to my REST API class and not to the CXF Servlet or CXF Framework in general. Or maybe I'm not taking the right approach to manage the log separation?

Thanks,
Diego.
________________________________
DISCLAIMER: Aquest missatge pot contenir informaci? confidencial. Si vost? no n'?s el destinatari, si us plau, esborri'l i faci'ns-ho saber immediatament a la seg?ent adre?a: legal@eurecat.org Si el destinatari d'aquest missatge no consent la utilitzaci? del correu electr?nic via Internet i la gravaci? de missatges, li preguem que ens ho comuniqui immediatament.

DISCLAIMER: Este mensaje puede contener informaci?n confidencial. Si usted no es el destinatario del mensaje, por favor b?rrelo y notif?quenoslo inmediatamente a la siguiente direcci?n: legal@eurecat.org Si el destinatario de este mensaje no consintiera la utilizaci?n del correo electr?nico v?a Internet y la grabaci?n de los mensajes, rogamos lo ponga en nuestro conocimiento de forma inmediata.

DISCLAIMER: Privileged/Confidential Information may be contained in this message. If you are not the addressee indicated in this message you should destroy this message, and notify us immediately to the following address: legal@eurecat.org. If the addressee of this message does not consent to the use of Internet e-mail and message recording, please notify us immediately.
________________________________



Re: Apache CXF log separation

Posted by Christian Schneider <ch...@die-schneider.net>.
You can configure logback as well as log4j to split logs by logger names.
So you can send all org.apache.cxf messages to one file and your own 
messages using another base for the logger names to some other file.

Christian

On 20.06.2016 17:46, Diego Delgado Roda wrote:
> Hello,
>
> I'll try to explain my situation as well as I can. given that I have little experience in Apache CXF in particular and in web application programming in general.
>
> I built and deployed a JAX-RS REST API as a WAR into my WSO2 Application Server (WSO2 AS). This WSO2 AS runs an Apache CXF 2.7.6 environment which contains the needed dependencies to run my REST API.
> Under WSO2 AS this CXF is configured to send log messages to Log4j framework. This can be verified in the following message of the WSO2 AS server startup log:
>
> 12:32:55.087 [localhost-startStop-1] DEBUG org.apache.cxf.common.logging.LogUtils[<clinit>:140] - Using org.apache.cxf.common.logging.Log4jLogger for logging.
>
> The problem arises when I want to use the SLF4J / Logback framework to log my REST API. The achieve that I put the needed dependencies under WEB-INF/lib.
> During the server startup one thing changes, the CXF framework now detects my SLF4J / logback framework and sends its log messages to my appenders configured in WEB-INF/classes/logback.xml. Again, this can be verified in the following message of the WSO2 AS server startup log:
>
> SLF4J: Class path contains multiple SLF4J bindings.
> SLF4J: Found binding in [bundleresource://460.fwk1889868818:1/org/slf4j/impl/StaticLoggerBinder.class]
> SLF4J: Found binding in [jar:file:/C:/Users/Diego/wso2as-5.2.1/repository/deployment/server/webapps/MYAPP_JAX-RS_1.0.0/WEB-INF/lib/logback-classic-1.1.3.jar!/org/slf4j/impl/StaticLoggerBinder.class]
> SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
> SLF4J: Actual binding is of type [ch.qos.logback.classic.util.ContextSelectorStaticBinder]
> 22:01:13.232 [localhost-startStop-1] DEBUG org.apache.cxf.common.logging.LogUtils[<clinit>:140] - Using org.apache.cxf.common.logging.Slf4jLogger for logging.
>
> The problem is that now my logback appenders are mixed with org.apache.cxf DEBUG log messages and my REST API log messages. So the purpose of isolate my REST API logs are not possible using this SLF4J / Logback approach.
>
> My question is if it's possible to make WEB-INF/lib only visible to my REST API class and not to the CXF Servlet or CXF Framework in general. Or maybe I'm not taking the right approach to manage the log separation?
>
> Thanks,
> Diego.
> ________________________________
> DISCLAIMER: Aquest missatge pot contenir informaci? confidencial. Si vost? no n'?s el destinatari, si us plau, esborri'l i faci'ns-ho saber immediatament a la seg?ent adre?a: legal@eurecat.org Si el destinatari d'aquest missatge no consent la utilitzaci? del correu electr?nic via Internet i la gravaci? de missatges, li preguem que ens ho comuniqui immediatament.
>
> DISCLAIMER: Este mensaje puede contener informaci?n confidencial. Si usted no es el destinatario del mensaje, por favor b?rrelo y notif?quenoslo inmediatamente a la siguiente direcci?n: legal@eurecat.org Si el destinatario de este mensaje no consintiera la utilizaci?n del correo electr?nico v?a Internet y la grabaci?n de los mensajes, rogamos lo ponga en nuestro conocimiento de forma inmediata.
>
> DISCLAIMER: Privileged/Confidential Information may be contained in this message. If you are not the addressee indicated in this message you should destroy this message, and notify us immediately to the following address: legal@eurecat.org. If the addressee of this message does not consent to the use of Internet e-mail and message recording, please notify us immediately.
> ________________________________
>
>
>


-- 
Christian Schneider
http://www.liquid-reality.de

Open Source Architect
http://www.talend.com