I am using ConversionPattern to display date, time and sessionID in transaction logging file. Included the below statements in log4j.xml file.
<appender name="transaction" class="org.apache.log4j.DailyRollingFileAppender">
<param name="File" value="C://logs/abc.tran"/>
<param name="DatePattern" value="'.'yyyyMMdd"/>
<param name="Append" value="true"/>
<param name="ImmediateFlush" value="true"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{yyyyMMdd HH:mm:ss,SSS} [%X{sessionID}] - %m%n"/>
</layout>
</appender>
After running the application I sometimes get empty sessionID in transaction log file. I included log.info statement in one of the
java file to print the session id. Session id is neither null or empty. It shows valid session id but the same is not displayed in transaction log file sometimes.
Transaction log output:
20110520 15:11:02,209 [] - 3798 X220_GETUSERAUTH Class Details: " ReorderUtil class; getSerialNumber(
String loginId, String serialNum, int callId) method."
Application log output:
20 May 2011 15:11:03,381 INFO [http-443-Processor22] modal.OrderServlet - sessionId--> 4186F233C819AE683E421F7483CD439A
Any idea how we can ensure session id is always displayed in transaction log file?