Discussion:
Log incoming message with the corresponding response
Sergey Maslov
2015-11-27 08:07:49 UTC
Permalink
Hi.
My application provides SOAP web services using CXF. I need to log incoming
request with the corresponding response from my webservice.
I've check the interceptor phases for the incoming chain but it looks like
I have no information about outgoing message body.
Maybe I should use some observer (like message observer for the outgoing
message)?
Could you help me?
--
*Sergey Maslov*
Jim Talbut
2015-11-27 10:47:33 UTC
Permalink
Post by Sergey Maslov
Hi.
My application provides SOAP web services using CXF. I need to log incoming
request with the corresponding response from my webservice.
I've check the interceptor phases for the incoming chain but it looks like
I have no information about outgoing message body.
Maybe I should use some observer (like message observer for the outgoing
message)?
Could you help me?
I wrote an interceptor (which unfortunately I can't open source) that
records every message in a database, along with a correlation ID and a
value to indicate whether it is an inbound/outbound request/response
(four possiblities).
The code was largely based on the logging interceptor
(https://github.com/apache/cxf/blob/master/core/src/main/java/org/apache/cxf/interceptor/LoggingInInterceptor.java).

There are two interceptors (in and out) both of which pass most of the
work on to a common class.
It also has options about where to put the result record - in live it
goes to a database and in test it outputs a bit like the logging
interceptor.

Jim
Sergey Maslov
2015-11-27 19:21:29 UTC
Permalink
Jim,
thank you for the answer, but that doesn't help me all.
I've checked , that in the BackChannelConduit class message is filled by
response with
message.put(HTTP_RESPONSE, response) so later this could be read at the
post-invoke phase.
I believe, this could help for the case I have message body. But according
to the contract, I need to send empty messages with different HTTP status
(for example, "202 - Accepted" as the response for some service methods.
How could I get and log this status? There is no information on that kind
in the message, as far as I investigated.
So my question is still actual.

Sergey Maslov
Post by Jim Talbut
Post by Sergey Maslov
Hi.
My application provides SOAP web services using CXF. I need to log incoming
request with the corresponding response from my webservice.
I've check the interceptor phases for the incoming chain but it looks like
I have no information about outgoing message body.
Maybe I should use some observer (like message observer for the outgoing
message)?
Could you help me?
I wrote an interceptor (which unfortunately I can't open source) that
records every message in a database, along with a correlation ID and a
value to indicate whether it is an inbound/outbound request/response (four
possiblities).
The code was largely based on the logging interceptor (
https://github.com/apache/cxf/blob/master/core/src/main/java/org/apache/cxf/interceptor/LoggingInInterceptor.java
).
There are two interceptors (in and out) both of which pass most of the
work on to a common class.
It also has options about where to put the result record - in live it goes
to a database and in test it outputs a bit like the logging interceptor.
Jim
--
*Sergey Maslov*
Andrei Shakirin
2015-11-29 19:26:17 UTC
Permalink
Hi,

If I get it correctly you just need to log service request - response pair?
Why not use standard CXF logging feature for that (http://cxf.apache.org/docs/debugging-and-logging.html#DebuggingandLogging-LoggingMessages)?
In every message CXF writes an id, helping to bind request to corresponded response:

ID: 1
Address: http://localhost:xxxx/services/myService
Http-Method: GET
Content-Type:
Headers: {accept-encoding=[gzip,deflate], Content-Type=[null], Host=[localhost:1
8040], User-Agent=[Jakarta Commons-HttpClient/3.1]}

ID: 1
Response-Code: 200
Content-Type: application/xml
Headers: {Content-Type=[application/xml], Date=[Mon, 04 May 2015 16:12:31 GMT]}
Payload: <?xml version="1.0" encoding="UTF-8" standalone="yes"?><ns2:MyElement xmlns:ns2="http://www.apache.org"
<ns2:globalStatus>SUCCESS</ns2:globalStatus><MyElement>
Regards,
Andrei.
-----Original Message-----
Sent: Freitag, 27. November 2015 09:08
Subject: Log incoming message with the corresponding response
Hi.
My application provides SOAP web services using CXF. I need to log incoming
request with the corresponding response from my webservice.
I've check the interceptor phases for the incoming chain but it looks like I have
no information about outgoing message body.
Maybe I should use some observer (like message observer for the outgoing
message)?
Could y
Christian Schneider
2015-11-29 19:51:20 UTC
Permalink
Hi Sergey,

CXF has a new logging feature since 3.1 now.

It provides a message id as well as an exchange id out of the box. It
even sends the message id over the wire so you can also correlate a sent
and received message.
Unfortunately I did not yet update the CXF documentation. I will do
this asap.

For now you can see:
http://liquid-reality.de/display/liquid/2015/06/08/Enterprise+ready+request+logging+with+CXF+3.1.0+and+elastic+search

The new logging feature by default logs using slf4j but it provides a
very simple SPI where you can hook in any logging backend you want.

Christian
Post by Sergey Maslov
Hi.
My application provides SOAP web services using CXF. I need to log incoming
request with the corresponding response from my webservice.
I've check the interceptor phases for the incoming chain but it looks like
I have no information about outgoing message body.
Maybe I should use some observer (like message observer for the outgoing
message)?
Could you help me?
Sergey Maslov
2015-11-30 05:59:06 UTC
Permalink
Andrey, Christian,
thank you.
That would help me much except just one thing:
I need to log requests and responses to the project MongoDB along with the
simple log file.
So we have special package dealing with logging to MongoDB (separate job
and threads), containing some additional information and message
trasnformations. This is caused by async interaction with some services. So
we can exchange multiple messages to track business process request status,
but we need to put to MongoDB the final response only.
With the Apache's built-in fiunctionality, we will need some other
mechanism to move logs into MongoDB. It looks like, we'll need some text
file log search and parsing process, capable to save log to external
storage (like MongoDB).
I have no experience here.
Cound we extend some CXF's logging classes to get the messag content on the
java code to fufil our business logging requirements?
Or is it better to write custom logger?
Thank you in advance.

Sergey Maslov

On Mon, Nov 30, 2015 at 1:51 AM, Christian Schneider <
Post by Christian Schneider
Hi Sergey,
CXF has a new logging feature since 3.1 now.
It provides a message id as well as an exchange id out of the box. It even
sends the message id over the wire so you can also correlate a sent and
received message.
Unfortunately I did not yet update the CXF documentation. I will do this
asap.
http://liquid-reality.de/display/liquid/2015/06/08/Enterprise+ready+request+logging+with+CXF+3.1.0+and+elastic+search
The new logging feature by default logs using slf4j but it provides a very
simple SPI where you can hook in any logging backend you want.
Christian
Post by Sergey Maslov
Hi.
My application provides SOAP web services using CXF. I need to log incoming
request with the corresponding response from my webservice.
I've check the interceptor phases for the incoming chain but it looks like
I have no information about outgoing message body.
Maybe I should use some observer (like message observer for the outgoing
message)?
Could you help me?
--
*Sergey Maslov*
Christian Schneider
2015-11-30 08:21:45 UTC
Permalink
You should be able to do the custom logging / filtering with the new
LoggingFeature.

See:
https://github.com/apache/cxf/blob/master/rt/features/logging/src/main/java/org/apache/cxf/ext/logging/LoggingFeature.java
https://github.com/apache/cxf/blob/master/rt/features/logging/src/main/java/org/apache/cxf/ext/logging/event/LogEventSender.java

You just need to implement the LogEventSender interface and set your
implementation in the LoggingFeature. Alternatively you can of course extend
LoggingFeature and set you implementation internally.

This is the default impl that logs to slf4j:
https://github.com/apache/cxf/blob/master/rt/features/logging/src/main/java/org/apache/cxf/ext/logging/slf4j/Slf4jEventSender.java

So as you see it is really easy to implement.

Christian
Post by Sergey Maslov
Andrey, Christian,
thank you.
I need to log requests and responses to the project MongoDB along with the
simple log file.
So we have special package dealing with logging to MongoDB (separate job
and threads), containing some additional information and message
trasnformations. This is caused by async interaction with some services. So
we can exchange multiple messages to track business process request status,
but we need to put to MongoDB the final response only.
With the Apache's built-in fiunctionality, we will need some other
mechanism to move logs into MongoDB. It looks like, we'll need some text
file log search and parsing process, capable to save log to external
storage (like MongoDB).
I have no experience here.
Cound we extend some CXF's logging classes to get the messag content on the
java code to fufil our business logging requirements?
Or is it better to write custom logger?
Thank you in advance.
Sergey Maslov
On Mon, Nov 30, 2015 at 1:51 AM, Christian Schneider <
Post by Christian Schneider
Hi Sergey,
CXF has a new logging feature since 3.1 now.
It provides a message id as well as an exchange id out of the box. It even
sends the message id over the wire so you can also correlate a sent and
received message.
Unfortunately I did not yet update the CXF documentation. I will do this
asap.
http://liquid-reality.de/display/liquid/2015/06/08/Enterprise+ready+request+logging+with+CXF+3.1.0+and+elastic+search
The new logging feature by default logs using slf4j but it provides a very
simple SPI where you can hook in any logging backend you want.
Christian
Post by Sergey Maslov
Hi.
My application provides SOAP web services using CXF. I need to log incoming
request with the corresponding response from my webservice.
I've check the interceptor phases for the incoming chain but it looks like
I have no information about outgoing message body.
Maybe I should use some observer (like message observer for the outgoing
message)?
Could you help me?
Sergey Maslov
2015-11-30 08:42:28 UTC
Permalink
Christian,
thank you!
It looks like it's just what I need!

Best regards,
Sergey Maslov

On Mon, Nov 30, 2015 at 2:21 PM, Christian Schneider <
Post by Christian Schneider
You should be able to do the custom logging / filtering with the new
LoggingFeature.
https://github.com/apache/cxf/blob/master/rt/features/logging/src/main/java/org/apache/cxf/ext/logging/LoggingFeature.java
https://github.com/apache/cxf/blob/master/rt/features/logging/src/main/java/org/apache/cxf/ext/logging/event/LogEventSender.java
You just need to implement the LogEventSender interface and set your
implementation in the LoggingFeature. Alternatively you can of course extend
LoggingFeature and set you implementation internally.
https://github.com/apache/cxf/blob/master/rt/features/logging/src/main/java/org/apache/cxf/ext/logging/slf4j/Slf4jEventSender.java
So as you see it is really easy to implement.
Christian
Post by Sergey Maslov
Andrey, Christian,
thank you.
I need to log requests and responses to the project MongoDB along with the
simple log file.
So we have special package dealing with logging to MongoDB (separate job
and threads), containing some additional information and message
trasnformations. This is caused by async interaction with some services. So
we can exchange multiple messages to track business process request status,
but we need to put to MongoDB the final response only.
With the Apache's built-in fiunctionality, we will need some other
mechanism to move logs into MongoDB. It looks like, we'll need some text
file log search and parsing process, capable to save log to external
storage (like MongoDB).
I have no experience here.
Cound we extend some CXF's logging classes to get the messag content on the
java code to fufil our business logging requirements?
Or is it better to write custom logger?
Thank you in advance.
Sergey Maslov
On Mon, Nov 30, 2015 at 1:51 AM, Christian Schneider <
Hi Sergey,
Post by Christian Schneider
CXF has a new logging feature since 3.1 now.
It provides a message id as well as an exchange id out of the box. It even
sends the message id over the wire so you can also correlate a sent and
received message.
Unfortunately I did not yet update the CXF documentation. I will do this
asap.
http://liquid-reality.de/display/liquid/2015/06/08/Enterprise+ready+request+logging+with+CXF+3.1.0+and+elastic+search
The new logging feature by default logs using slf4j but it provides a very
simple SPI where you can hook in any logging backend you want.
Christian
Hi.
Post by Sergey Maslov
My application provides SOAP web services using CXF. I need to log incoming
request with the corresponding response from my webservice.
I've check the interceptor phases for the incoming chain but it looks like
I have no information about outgoing message body.
Maybe I should use some observer (like message observer for the outgoing
message)?
Could you help me?
--
*Sergey Maslov*
Sergey Maslov
2015-12-04 06:37:35 UTC
Permalink
Guys, Christian,
Could I set LoggingFeature for logging application requests acting as a web
service client?
I looks like, it is for endpoints only.
What could I use for ws client logging to log request and response (with
the similar functionality as LoggingFeature)?

Sergey Maslov
Post by Sergey Maslov
Christian,
thank you!
It looks like it's just what I need!
Best regards,
Sergey Maslov
On Mon, Nov 30, 2015 at 2:21 PM, Christian Schneider <
Post by Christian Schneider
You should be able to do the custom logging / filtering with the new
LoggingFeature.
https://github.com/apache/cxf/blob/master/rt/features/logging/src/main/java/org/apache/cxf/ext/logging/LoggingFeature.java
https://github.com/apache/cxf/blob/master/rt/features/logging/src/main/java/org/apache/cxf/ext/logging/event/LogEventSender.java
You just need to implement the LogEventSender interface and set your
implementation in the LoggingFeature. Alternatively you can of course extend
LoggingFeature and set you implementation internally.
https://github.com/apache/cxf/blob/master/rt/features/logging/src/main/java/org/apache/cxf/ext/logging/slf4j/Slf4jEventSender.java
So as you see it is really easy to implement.
Christian
Post by Sergey Maslov
Andrey, Christian,
thank you.
I need to log requests and responses to the project MongoDB along with the
simple log file.
So we have special package dealing with logging to MongoDB (separate job
and threads), containing some additional information and message
trasnformations. This is caused by async interaction with some services. So
we can exchange multiple messages to track business process request status,
but we need to put to MongoDB the final response only.
With the Apache's built-in fiunctionality, we will need some other
mechanism to move logs into MongoDB. It looks like, we'll need some text
file log search and parsing process, capable to save log to external
storage (like MongoDB).
I have no experience here.
Cound we extend some CXF's logging classes to get the messag content on the
java code to fufil our business logging requirements?
Or is it better to write custom logger?
Thank you in advance.
Sergey Maslov
On Mon, Nov 30, 2015 at 1:51 AM, Christian Schneider <
Hi Sergey,
Post by Christian Schneider
CXF has a new logging feature since 3.1 now.
It provides a message id as well as an exchange id out of the box. It even
sends the message id over the wire so you can also correlate a sent and
received message.
Unfortunately I did not yet update the CXF documentation. I will do this
asap.
http://liquid-reality.de/display/liquid/2015/06/08/Enterprise+ready+request+logging+with+CXF+3.1.0+and+elastic+search
The new logging feature by default logs using slf4j but it provides a very
simple SPI where you can hook in any logging backend you want.
Christian
Hi.
Post by Sergey Maslov
My application provides SOAP web services using CXF. I need to log incoming
request with the corresponding response from my webservice.
I've check the interceptor phases for the incoming chain but it looks like
I have no information about outgoing message body.
Maybe I should use some observer (like message observer for the outgoing
message)?
Could you help me?
--
*Sergey Maslov*
--
*Sergey Maslov*
Sergey Maslov
2015-12-04 06:48:22 UTC
Permalink
Thank you!
I've cleared up this by myself. I can configure it like the usual feature
in the features section!

Sergey Maslov
Post by Sergey Maslov
Guys, Christian,
Could I set LoggingFeature for logging application requests acting as a
web service client?
I looks like, it is for endpoints only.
What could I use for ws client logging to log request and response (with
the similar functionality as LoggingFeature)?
Sergey Maslov
Post by Sergey Maslov
Christian,
thank you!
It looks like it's just what I need!
Best regards,
Sergey Maslov
On Mon, Nov 30, 2015 at 2:21 PM, Christian Schneider <
Post by Christian Schneider
You should be able to do the custom logging / filtering with the new
LoggingFeature.
https://github.com/apache/cxf/blob/master/rt/features/logging/src/main/java/org/apache/cxf/ext/logging/LoggingFeature.java
https://github.com/apache/cxf/blob/master/rt/features/logging/src/main/java/org/apache/cxf/ext/logging/event/LogEventSender.java
You just need to implement the LogEventSender interface and set your
implementation in the LoggingFeature. Alternatively you can of course extend
LoggingFeature and set you implementation internally.
https://github.com/apache/cxf/blob/master/rt/features/logging/src/main/java/org/apache/cxf/ext/logging/slf4j/Slf4jEventSender.java
So as you see it is really easy to implement.
Christian
Post by Sergey Maslov
Andrey, Christian,
thank you.
I need to log requests and responses to the project MongoDB along with the
simple log file.
So we have special package dealing with logging to MongoDB (separate job
and threads), containing some additional information and message
trasnformations. This is caused by async interaction with some services. So
we can exchange multiple messages to track business process request status,
but we need to put to MongoDB the final response only.
With the Apache's built-in fiunctionality, we will need some other
mechanism to move logs into MongoDB. It looks like, we'll need some text
file log search and parsing process, capable to save log to external
storage (like MongoDB).
I have no experience here.
Cound we extend some CXF's logging classes to get the messag content on the
java code to fufil our business logging requirements?
Or is it better to write custom logger?
Thank you in advance.
Sergey Maslov
On Mon, Nov 30, 2015 at 1:51 AM, Christian Schneider <
Hi Sergey,
Post by Christian Schneider
CXF has a new logging feature since 3.1 now.
It provides a message id as well as an exchange id out of the box. It even
sends the message id over the wire so you can also correlate a sent and
received message.
Unfortunately I did not yet update the CXF documentation. I will do this
asap.
http://liquid-reality.de/display/liquid/2015/06/08/Enterprise+ready+request+logging+with+CXF+3.1.0+and+elastic+search
The new logging feature by default logs using slf4j but it provides a very
simple SPI where you can hook in any logging backend you want.
Christian
Hi.
Post by Sergey Maslov
My application provides SOAP web services using CXF. I need to log incoming
request with the corresponding response from my webservice.
I've check the interceptor phases for the incoming chain but it looks like
I have no information about outgoing message body.
Maybe I should use some observer (like message observer for the outgoing
message)?
Could you help me?
--
*Sergey Maslov*
--
*Sergey Maslov*
--
*Sergey Maslov*
Continue reading on narkive:
Loading...