hi! All,
          i'm using log4j's MDC within struts application,but i'm facing some problem. 
pls guide me. this is what i'm doing..

1. i'm creating an instance of logger in each action class.
    private final static Logger log = 
Logger.getLogger(admin.middle.PAF1Entity.class.getName());


2. with in actionPerform() method. 
   MDC.put("username", session.getAttribute("userName"));


3. and in each action like save , delete & modify , i'm using
    if(action!= null && action.equals("resetAll"))
     {log.info("Actions --: " + "Resetting ALL ");}
    if(action!= null && action.equals("Save"))
     {log.info("Actions --: " + "Saving ");}

but when i click on the save/delete action ..i get the following @ struts console

2003-03-18 06:40:23 - Ctx( /medicare ): 500 R( /medicare + /Authorisationone.do
+ null) No action instance for path /Authorisationone could be created

but if i remove/comment the logger instance  this doesn't happen. i'm not able to 
figure out y? this is happening..

This is my config-MDC properties file
----------------------------------------------------------------------------------------------------------------------------------------------
# For this example, we are just going to log to the console
#
log4j.appender.R=org.apache.log4j.ConsoleAppender

#
# When logging using the ConsoleAppender, the following value tells how and
# what to log. The SimpleLayout simply logs the level of the message and
# the message itself.
#
log4j.appender.R.layout=org.apache.log4j.SimpleLayout


#
# In this configuration we are going to use MDC to log messages for a special
# category that we define in the GetCommentsServlet
# So first define the level of logging for the category and add a new appender
# to it.
#
admin.middle.PAF1Entity=debug, R1
admin.middle.PAF2Entity=info, R2
admin.middle.PAF3Entity=info, R2

#
# For this appender and logger we are only interested in the messages from this
# logger. We dont want the messages to print twice, first from the root appender
# and next one from R1 appender. So we set the additivity to false.
#
admin.middle.PAF1Entity=false
admin.middle.PAF2Entity=false

#
# For this we will use the RollingFileAppender and call the log file as MDC.log
#

log4j.appender.R1=org.apache.log4j.RollingFileAppender
log4j.appender.R1.File=c:/tomcat/webapps/medicare/log/authorisation1.log

log4j.appender.R2=org.apache.log4j.RollingFileAppender
log4j.appender.R2.File=c:/tomcat/webapps/medicare/log/authorisation2.log

#
# This is the maximum size of this file, after which it is rolled over. The name
# of the backup file will be MDC.log.1.. and so on. After 2 backups, the file names
# are reused. This is set up by the MaxBackupIndex.
#
log4j.appender.R1.MaxFileSize=100KB
log4j.appender.R2.MaxFileSize=100KB

# Keep two backup files
log4j.appender.R1.MaxBackupIndex=2


#
# The layout is the PatternLayout
#

log4j.appender.R1.layout=org.apache.log4j.PatternLayout
log4j.appender.R2.layout=org.apache.log4j.PatternLayout

#
# and the Conversion pattern includes MDC content (%X{ID})
#
log4j.appender.R1.layout.ConversionPattern=%p - [%X{User}] - %m%n
log4j.appender.R2.layout.ConversionPattern=%p - [%X{User}] - %c - %d - %m%n
---------------------------------------------------------------------------------------------------------------------------------------------------

TIA

rgds,
Dinesh B Sampangi

Reply via email to