On 14/1/05 2:40 pm, "Margarida Sargento" <[EMAIL PROTECTED]>
wrote:

> Hello
> 
> 
> 
> I am new to Struts. My first applications are examples that I download
> from several web sites. One of them logs the forms data with:
> servlet.log("...");
> 

To solve of your logging problems use Log4j
(http://logging.apache.org/log4j/docs/)


Try adding this to your class:

protected static Logger log = Logger.getLogger(yourclass.class);


public yourMethod() {

if (log.isDebugEnabled()) {
    log.debug(yourdata);
}

}

put this file on your classpath (in your web-app it should be
WEB-INF/classes):

(log4j.properties)
log4j.appender.stdout=org.apache.log4j.ConsoleAppender

log4j.appender.stdout.layout=org.apache.log4j.PatternLayout

log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) - %m%n


log4j.logger.packageofyourclass=DEBUG, myclasslogger

log4j.appender.myclasslogger=org.apache.log4j.RollingFileAppender

log4j.appender.myclasslogger=/somepath/logs/yourpackage.log

log4j.appender.myclasslogger.MaxFileSize=300KB

log4j.appender.myclasslogger.MaxBackupIndex=1

log4j.appender.myclasslogger.layout=org.apache.log4j.PatternLayout

log4j.appender.myclasslogger.layout.ConversionPattern=%d{ABSOLUTE} - %p %c -
%m%n


This will solve all logging problems in every class, if you replicate the
same behaviour.

Pedro Salgado


> I have already search information about this and the Struts home page
> refers this too. However I don't know where the logs are being saved. I
> can not find the file and the corresponding path.
> 
> 
> 
> If you can help me, please reply.
> 
> Thank you very much.
> 
> 
> 
> Ana Margarida Sargento
> 
> 
> 
> 


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

Reply via email to