Hi Viral,

Yeah looks like pattern difference, the ConversionPattern I am using for
logging to a file is :

log4j.appender.Roll.layout.ConversionPattern=%x %d{yyyy.MM.dd HH:mm:ss,SSS}
%5p [%t] (%c:%-4L %M) - %m%n


Here is the complete prop file

########################################################
#
# Log4J Properties
#
########################################################
# Developer Settings
# log4j.rootCategory=debug, stdout, Roll
# Deployment Settings
log4j.rootCategory=info, Roll

# stdout - Logging onto the console
#log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout=org.apache.log4j.FileAppender
log4j.appender.stdout.File=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%x %d{HH:mm:ss,SSS} %5p [%t]
(%c:%-4L %M) - %m%n

# Roll - Logging into a file
log4j.appender.Roll=org.apache.log4j.RollingFileAppender
log4j.appender.Roll.File=${InstanceName}.log
log4j.appender.Roll.MaxFileSize=10MB
log4j.appender.Roll.MaxBackupIndex=100
log4j.appender.Roll.layout=org.apache.log4j.PatternLayout
log4j.appender.Roll.layout.ConversionPattern=%x %d{yyyy.MM.dd HH:mm:ss,SSS}
%5p [%t] (%c:%-4L %M) - %m%n


########################################################
# Framework: core
########################################################
log4j.category.CoreLog=INFO
log4j.category.CoreBTBUtility=INFO
log4j.category.CoreFareMainL=FATAL
....
....


Hope this helps


Cheers
Apurva Goswami
Release Manager 

ARNOLD Travel Technology Pty Limited 
685 South Dowling Street, Surry Hills, NSW 2016, Australia 
Direct telephone:     61 2 9318-8142 




-----Original Message-----
From: Viral_Thakkar [mailto:[EMAIL PROTECTED] 
Sent: Monday, July 12, 2004 11:36 PM
To: Struts Users Mailing List
Subject: RE: logging


Hi Apurva,

We are having a class level variable as you mentioned as below

org.apache.log4j.Category cat =
org.apache.log4j.Category.getInstance(ResResourceManager.class.getName()
);

I think the difference will be in the 

log4j.appender.R.layout.ConversionPattern=%d, [%t], %-5p, %c, - %m%n

in log4jconfig.properties file.

Could you please let me know log4j.appender.R.layout.ConversionPattern
value ..??

Thanks,
Viral
-----Original Message-----
From: Apurva Goswami [mailto:[EMAIL PROTECTED] 
Sent: Monday, July 12, 2004 11:50 AM
To: 'Struts Users Mailing List'
Subject: RE: logging

Try 

Put these lines on top of your class file
// Log4j
// Log4j with Try-Catch: try {...} catch (Exception e) { cat.error(e, e); }
static org.apache.log4j.Category cat =
org.apache.log4j.Category.getInstance("File Name".class.getName());

E.g. 
static org.apache.log4j.Category cat =
org.apache.log4j.Category.getInstance(ResResourceManager.class.getName()
);


Use these methods as per your requirement
cat.debug() - >  cat.debug("", e);
cat.error() - >  cat.error("", e);
cat.fatal() - >  cat.fatal("", e);

It prints the method name in the log and you do not need to pass.

E.g. if I use statement :
if (cat.isDebugEnabled()) cat.debug("Retrieved " +
agencyDepPortsDropDownList.count() + " " + countrycode + " Ports");

I get this in my log file :
(CoreFareMainL:3515 initAgencyDepPortsDropDownList) - Retrieved 117 AU Ports

(Class file: linenumber method ) - string message

Hope it helps

Cheers
Apurva


-----Original Message-----
From: Viral_Thakkar [mailto:[EMAIL PROTECTED] 
Sent: Monday, July 12, 2004 4:03 PM
To: Struts Users Mailing List
Subject: logging


Hi All,
 
I am using commons-logging (using log4j) for logging..
 
We do following logging style...
 
if (logger.isDebugEnabled())
{
  logger.debug("Method Name : + some Message");
}
 
Here can we get the method name using java reflection or some other way so
that no need to pass the method name while logging the message ..???
 
Regards,
Viral

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to