Posts Tagged Log4j

Axis2 + Log4j

Problem: How to enable Log4j logging inside Axis2

Solution: When application is deployed as .aar (axis archive) file, even if log4j settings are done properly and logging is enabled, there are cases where log file is either not generated or logging is not happening.

This can be resolved by checking out the Axis2 source code from apache website (instead of checking out the axis2.war)  and replacing the file with the custom log4j.xml and log4j.dtd and then build the  axis2.war using maven

1. Check out the axis2 source code distribution

2. Navigate to src/main/webapp/WEB-INF/classes

3. Locate and replace with your log4j.xml and log4j.dtd

4. Inside log4j.xml , FileAppender shall  look like this

<appender name=”FileAppender”>

<param name=”File” value=”logs/newlog.log”/>

<!–Other Params goes here –>


5.  Now build the axis2.war and package the app as war file (using maven or so) to deploy axis2 inside
application container as a webapp. When the application container is started, axis2.war is exploded to axis2

6. Upon the application is accessed, newlog.log will be created and the generated logs can be viewed, provided log statements
are available and set to appropriate levels like Debug for debugging.


Leave a comment