on ‎2018 Aug 13 10:27 PM
Hi there,
Anyone here who implemented logging for all OCC API request/response using any library like jersey.
Any help is appreciable.
Thanks
Anil
Request clarification before answering.
: Your OCC must be implemented in some extension, right ? in that extension, you must have a web.xml and an application configuration file. Add the request logger in the filter chain in that application configuration file and you should be good.
Basically it is all about adding a filter before your request gets processed, it does not matter if it is storefront or web services or OCC or process engine.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi : Create a Request Logging Filter which implements OncePerRequestFilter and define this filter in your extension's spring-filter.xml file. See example below.
<alias name="defaultStorefrontTenantDefaultFilterChainList" alias="storefrontTenantDefaultFilterChainList" />
<util:list id="defaultStorefrontTenantDefaultFilterChainList">
<!-- generic platform filters -->
<ref bean="storefrontSessionFilter"/>
<!-- <ref bean="addOnDevelopmentFilter"/> -->
<!-- filter to log the current request -->
<ref bean="requestLoggerFilter"/>
<!-- filter to setup the cms integration -->
<ref bean="cmsSiteFilter"/>
<!-- filter to initialize the storefront -->
<ref bean="storefrontFilter"/>
<!-- filter to handle url encoding attributes -->
<ref bean="urlEncoderFilter"/>
<!-- Security -->
<ref bean="springSecurityFilterChain"/>
<!-- filter to log out guest user if he/she attempts to access a page outside of checkout flow -->
<ref bean="anonymousCheckoutFilter"/>
<!-- filter to restore items in cart -->
<ref bean="cartRestorationFilter"/>
</util:list>
<bean id="requestLoggerFilter" class="com.xxx.storefront.filters.RequestLoggerFilter">
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The proposed solution above does cover your requirements.
A quick google search provides several implementations for the filter. Examples below.
https://gist.github.com/int128/e47217bebdb4c402b2ffa7cc199307ba https://gist.github.com/freemanh/b896a70a21fddb8e2aea2cf08725eb64
There is also a guide here: https://www.baeldung.com/spring-http-logging
Edit: Of course you would be editing the defaultCommerceWebServicesFilterChainListV1 (or V2 if you are using that version) and not the storefront filter chain. The storefront and OCC WS are both using the spring web ecosystem.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.