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 log4j.properties 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 log4j.properties 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 –>

</appender>

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
directory

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.

,

  1. Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: