Rotating HTTP Access logs in WSO2 products in Windows/Linux environments.

Lashan Sivaganeshan
1 min readSep 17, 2018

--

As explained in the following document [1], wso2 products provide the capability to log HTTP Requests/Responses which are helpful to monitor your application’s usage activities. The above access logging is performed by valves that implement org.apache.catalina.AccessLog interface [2].

Due to the excessive growth of the above access log files (normally in the <Product_Home>/repository/logs directory), there can be requirements to rotate (write logs to new files).

It is possible to rotate logs based on time intervals by changing the configurations of the catalina-server.xml (in <Product_Home>/repository/conf/tomcat) by adding the fileDateFormat attribute to the AccessLogValve as follows. This is explained in the following document [3] as well.

<Valve className="org.apache.catalina.valves.AccessLogValve" directory="${carbon.home}/repository/logs"
prefix="http_access_" suffix=".log"
pattern="combined" fileDateFormat="yyyy-MM-dd.HH"/>

The pattern used above (yyyy-MM-dd.HH) is described in the tomcat document [2] and is supposed to rotate the access logs on an hourly base. This works exactly as expected in Linux environments. But due to file naming limitations, the above pattern does not work in some Windows environments.

For Windows environments, once the pattern is set as follows, the access logs get rotated successfully creating a new file each hour.

fileDateFormat="yyyy-MM-dd-HH"

Thanks,
Cheers

References:

[1]. https://docs.wso2.com/display/ADMIN44x/HTTP+Access+Logging

[2]. https://tomcat.apache.org/tomcat-7.0-doc/config/valve.html#Access_Log_Valve

[3]. https://docs.wso2.com/display/Carbon440/Configuring+catalina-server.xml

--

--

Lashan Sivaganeshan

What you search is out there. It's a matter of pressing the right keys.