You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cxf.apache.org by "Freeman Yue Fang (Jira)" <ji...@apache.org> on 2021/09/10 14:40:00 UTC

[jira] [Commented] (CXF-8595) Incorrect resource name used to log message content for rest messages

    [ https://issues.apache.org/jira/browse/CXF-8595?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17413219#comment-17413219 ] 

Freeman Yue Fang commented on CXF-8595:
---------------------------------------

Hi [~baiglin],

Thanks for raising this problem!

Are you interested in sending a PR to fix it?

Freeman

> Incorrect resource name used to log message content for rest messages 
> ----------------------------------------------------------------------
>
>                 Key: CXF-8595
>                 URL: https://issues.apache.org/jira/browse/CXF-8595
>             Project: CXF
>          Issue Type: Bug
>          Components: logging
>    Affects Versions: 3.4.4
>            Reporter: Baptiste AIGLIN
>            Priority: Minor
>
> Hello. 
> The context is message logs in case of rest services exposed when we have multiple resources exposed on the same JAX-RS server.
> What we see is the current logging name for message logs look like:
> <org.apache.cxf.services.ResourceClass.REQ_IN>
> <org.apache.cxf.services.ResourceClass.RESP_OUT>
>  
> However it is not always the correct resource class name that is logged, the request path does not match the resource path but on another resource exposed on the server.
>  
> After investigation I could find that the name comes from org.apache.cxf.jaxrs.JAXRSServiceImpl#getName used to create the endpoint info org.apache.cxf.jaxrs.AbstractJAXRSFactoryBean#createEndpointInfo
>  
> Where we can see:
> {{ public QName getName() {}}
> {{ if (serviceName != null) {}}
> {{ return serviceName;}}
> {{ }}}
> {{ if (address == null && !classResourceInfos.isEmpty()) {}}
> {{ Class<?> primaryClass = classResourceInfos.get(0).getServiceClass();}}
> {{ String ns = PackageUtils.getNamespace(PackageUtils.getPackageName(primaryClass));}}
> {{ return new QName(ns, primaryClass.getSimpleName());}}
> {{ }}}
> {{ return new QName(address, "WebClient");}}
> {{ }}}
>  
> And we can see the first resource found is used as name. but this does not always reflect the class targetted. 
> This name is used to log the message there org.apache.cxf.ext.logging.event.DefaultLogEventMapper#setEpInfo
> {{ event.setPortTypeName(endpoint.getName());}}
> But while debugging I could see that the message exchange actually contains the current class resource definition at the key "root.resource.class" set by the JAXRSInInterceptor, and this would actually set the correct class name.
> Thanks and best regards.
> Baptiste.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)