You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Loh Kok Jeng <ko...@gmail.com> on 2010/06/03 12:06:55 UTC

Logging Inbound and Outbound message for REST Server

Hi,

I'm implementing a REST server using CXFNonSpringJaxrsServlet.  Below
is a snippet of my REST server.

Question: how can I log inbound and outbound message for this REST server?

public class RestApp extends Application {

        @Override
	public Set<Class<?>> getClasses() {
		// TODO Auto-generated method stub
		Set<Class<?>> set = new HashSet<Class<?>>();
		
		set.add(SomeServiceJaxRS.class);
        }
}


regards,
Loh Kok Jeng

Re: Logging Inbound and Outbound message for REST Server

Posted by Loh Kok Jeng <ko...@gmail.com>.
Hi Sergey,

Many thanks.  I have tried your approach.  Instead of using providers,
I still use the interceptors with jaxrs.serviceClasses.  The
interceptors can now log, but instead of the log files specified in
log4j.properties, it logs to stdout, i.e. catalina.out.  I have done
the configuration to the CXF to use log4j and I can log to the
specified log files within my app, but interceptors still logs to
catalina.out.

Any idea?


regards,
Loh Kok Jeng



On 7 June 2010 01:33, Sergey Beryozkin <sb...@gmail.com> wrote:
> Hi
>
> There's a bug there (to be fixed) which is to do with jaxrs.inInterceptors
> and jaxrs.outInterceptors being ignored when jaxrs Application class is
> being used to provide info about service classes and providers. Just user
> jaxrs.serviceClasses and jaxrs.providers instead at the moment - and you'll
> see the logging interceptors working
>
> cheers, Sergey
>
> On Fri, Jun 4, 2010 at 9:31 AM, Loh Kok Jeng <ko...@gmail.com> wrote:
>
>> Hi Sergey,
>>
>> I added the params in web.xml but JAXRS still does not log inbound and
>> outbound messages.  FYI, I'm still using 2.2.5, and I checked the set
>> Interceptor are implemented in CXFNonSpringJaxRsServlet.
>>
>> regards,
>> Loh Kok Jeng
>>
>>
>>
>> On 4 June 2010 15:46, Loh Kok Jeng <ko...@gmail.com> wrote:
>> > Hi Sergey,
>> >
>> > Many thanks.
>> >
>> > Do u mean add the following to web.xml?
>> >
>> >         <init-param>
>> >              <param-name>jaxrs.inInterceptors</param-name>
>> >
>>  <param-value>org.apache.cxf.interceptor.LoggingInInterceptor</param-value>
>> >         </init-param>
>> >
>> >         <init-param>
>> >              <param-name>jaxrs.outInterceptors</param-name>
>> >
>>  <param-value>org.apache.cxf.interceptor.LoggingOutInterceptor</param-value>
>> >         </init-param>
>> >
>> > regards,
>> > Loh Kok Jeng
>> >
>> >
>> >
>> > On 4 June 2010 04:39, Sergey Beryozkin <sb...@gmail.com> wrote:
>> >> Hi
>> >>
>> >> You'll need to register CXF LoggingInInterceptor and
>> LoggingOutInterceptor
>> >> using
>> >>
>> >> jaxrs.inInterceptors and jaxrs.outInterceptors servlets parameters
>> >>
>> >> cheers, Sergey
>> >>
>> >>
>> >> On Thu, Jun 3, 2010 at 11:06 AM, Loh Kok Jeng <ko...@gmail.com>
>> wrote:
>> >>
>> >>> Hi,
>> >>>
>> >>> I'm implementing a REST server using CXFNonSpringJaxrsServlet.  Below
>> >>> is a snippet of my REST server.
>> >>>
>> >>> Question: how can I log inbound and outbound message for this REST
>> server?
>> >>>
>> >>> public class RestApp extends Application {
>> >>>
>> >>>        @Override
>> >>>        public Set<Class<?>> getClasses() {
>> >>>                // TODO Auto-generated method stub
>> >>>                Set<Class<?>> set = new HashSet<Class<?>>();
>> >>>
>> >>>                set.add(SomeServiceJaxRS.class);
>> >>>        }
>> >>> }
>> >>>
>> >>>
>> >>> regards,
>> >>> Loh Kok Jeng
>> >>>
>> >>
>> >
>>
>

Re: Logging Inbound and Outbound message for REST Server

Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi

There's a bug there (to be fixed) which is to do with jaxrs.inInterceptors
and jaxrs.outInterceptors being ignored when jaxrs Application class is
being used to provide info about service classes and providers. Just user
jaxrs.serviceClasses and jaxrs.providers instead at the moment - and you'll
see the logging interceptors working

cheers, Sergey

On Fri, Jun 4, 2010 at 9:31 AM, Loh Kok Jeng <ko...@gmail.com> wrote:

> Hi Sergey,
>
> I added the params in web.xml but JAXRS still does not log inbound and
> outbound messages.  FYI, I'm still using 2.2.5, and I checked the set
> Interceptor are implemented in CXFNonSpringJaxRsServlet.
>
> regards,
> Loh Kok Jeng
>
>
>
> On 4 June 2010 15:46, Loh Kok Jeng <ko...@gmail.com> wrote:
> > Hi Sergey,
> >
> > Many thanks.
> >
> > Do u mean add the following to web.xml?
> >
> >         <init-param>
> >              <param-name>jaxrs.inInterceptors</param-name>
> >
>  <param-value>org.apache.cxf.interceptor.LoggingInInterceptor</param-value>
> >         </init-param>
> >
> >         <init-param>
> >              <param-name>jaxrs.outInterceptors</param-name>
> >
>  <param-value>org.apache.cxf.interceptor.LoggingOutInterceptor</param-value>
> >         </init-param>
> >
> > regards,
> > Loh Kok Jeng
> >
> >
> >
> > On 4 June 2010 04:39, Sergey Beryozkin <sb...@gmail.com> wrote:
> >> Hi
> >>
> >> You'll need to register CXF LoggingInInterceptor and
> LoggingOutInterceptor
> >> using
> >>
> >> jaxrs.inInterceptors and jaxrs.outInterceptors servlets parameters
> >>
> >> cheers, Sergey
> >>
> >>
> >> On Thu, Jun 3, 2010 at 11:06 AM, Loh Kok Jeng <ko...@gmail.com>
> wrote:
> >>
> >>> Hi,
> >>>
> >>> I'm implementing a REST server using CXFNonSpringJaxrsServlet.  Below
> >>> is a snippet of my REST server.
> >>>
> >>> Question: how can I log inbound and outbound message for this REST
> server?
> >>>
> >>> public class RestApp extends Application {
> >>>
> >>>        @Override
> >>>        public Set<Class<?>> getClasses() {
> >>>                // TODO Auto-generated method stub
> >>>                Set<Class<?>> set = new HashSet<Class<?>>();
> >>>
> >>>                set.add(SomeServiceJaxRS.class);
> >>>        }
> >>> }
> >>>
> >>>
> >>> regards,
> >>> Loh Kok Jeng
> >>>
> >>
> >
>

Re: Logging Inbound and Outbound message for REST Server

Posted by Loh Kok Jeng <ko...@gmail.com>.
Hi Sergey,

I added the params in web.xml but JAXRS still does not log inbound and
outbound messages.  FYI, I'm still using 2.2.5, and I checked the set
Interceptor are implemented in CXFNonSpringJaxRsServlet.

regards,
Loh Kok Jeng



On 4 June 2010 15:46, Loh Kok Jeng <ko...@gmail.com> wrote:
> Hi Sergey,
>
> Many thanks.
>
> Do u mean add the following to web.xml?
>
>         <init-param>
>              <param-name>jaxrs.inInterceptors</param-name>
>              <param-value>org.apache.cxf.interceptor.LoggingInInterceptor</param-value>
>         </init-param>
>
>         <init-param>
>              <param-name>jaxrs.outInterceptors</param-name>
>              <param-value>org.apache.cxf.interceptor.LoggingOutInterceptor</param-value>
>         </init-param>
>
> regards,
> Loh Kok Jeng
>
>
>
> On 4 June 2010 04:39, Sergey Beryozkin <sb...@gmail.com> wrote:
>> Hi
>>
>> You'll need to register CXF LoggingInInterceptor and LoggingOutInterceptor
>> using
>>
>> jaxrs.inInterceptors and jaxrs.outInterceptors servlets parameters
>>
>> cheers, Sergey
>>
>>
>> On Thu, Jun 3, 2010 at 11:06 AM, Loh Kok Jeng <ko...@gmail.com> wrote:
>>
>>> Hi,
>>>
>>> I'm implementing a REST server using CXFNonSpringJaxrsServlet.  Below
>>> is a snippet of my REST server.
>>>
>>> Question: how can I log inbound and outbound message for this REST server?
>>>
>>> public class RestApp extends Application {
>>>
>>>        @Override
>>>        public Set<Class<?>> getClasses() {
>>>                // TODO Auto-generated method stub
>>>                Set<Class<?>> set = new HashSet<Class<?>>();
>>>
>>>                set.add(SomeServiceJaxRS.class);
>>>        }
>>> }
>>>
>>>
>>> regards,
>>> Loh Kok Jeng
>>>
>>
>

Re: Logging Inbound and Outbound message for REST Server

Posted by Loh Kok Jeng <ko...@gmail.com>.
Hi Sergey,

Many thanks.

Do u mean add the following to web.xml?

         <init-param>
              <param-name>jaxrs.inInterceptors</param-name>
              <param-value>org.apache.cxf.interceptor.LoggingInInterceptor</param-value>
         </init-param>

         <init-param>
              <param-name>jaxrs.outInterceptors</param-name>
              <param-value>org.apache.cxf.interceptor.LoggingOutInterceptor</param-value>
         </init-param>

regards,
Loh Kok Jeng



On 4 June 2010 04:39, Sergey Beryozkin <sb...@gmail.com> wrote:
> Hi
>
> You'll need to register CXF LoggingInInterceptor and LoggingOutInterceptor
> using
>
> jaxrs.inInterceptors and jaxrs.outInterceptors servlets parameters
>
> cheers, Sergey
>
>
> On Thu, Jun 3, 2010 at 11:06 AM, Loh Kok Jeng <ko...@gmail.com> wrote:
>
>> Hi,
>>
>> I'm implementing a REST server using CXFNonSpringJaxrsServlet.  Below
>> is a snippet of my REST server.
>>
>> Question: how can I log inbound and outbound message for this REST server?
>>
>> public class RestApp extends Application {
>>
>>        @Override
>>        public Set<Class<?>> getClasses() {
>>                // TODO Auto-generated method stub
>>                Set<Class<?>> set = new HashSet<Class<?>>();
>>
>>                set.add(SomeServiceJaxRS.class);
>>        }
>> }
>>
>>
>> regards,
>> Loh Kok Jeng
>>
>

Re: Logging Inbound and Outbound message for REST Server

Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi

You'll need to register CXF LoggingInInterceptor and LoggingOutInterceptor
using

jaxrs.inInterceptors and jaxrs.outInterceptors servlets parameters

cheers, Sergey


On Thu, Jun 3, 2010 at 11:06 AM, Loh Kok Jeng <ko...@gmail.com> wrote:

> Hi,
>
> I'm implementing a REST server using CXFNonSpringJaxrsServlet.  Below
> is a snippet of my REST server.
>
> Question: how can I log inbound and outbound message for this REST server?
>
> public class RestApp extends Application {
>
>        @Override
>        public Set<Class<?>> getClasses() {
>                // TODO Auto-generated method stub
>                Set<Class<?>> set = new HashSet<Class<?>>();
>
>                set.add(SomeServiceJaxRS.class);
>        }
> }
>
>
> regards,
> Loh Kok Jeng
>