Do you have the log4j.jar file anywhere?  It would be difficult to do
log4j logging with out it in Tomcat's common/lib
 
Here is a basic configuration file I use, placed under my webapp's
WEB-INF/classes:

#log4j.properties
log4j.rootCategory=DEBUG, filer, chainsaw

log4j.appender.filer=org.apache.log4j.FileAppender
log4j.appender.filer.File=c:/webapps/IDM/WEB-INF/logs/output.log
# Control the maximum log file size
# log4j.appender.filer.MaxFileSize=100KB
# Archive log files (one backup file here)
# log4j.appender.filer.MaxBackupIndex=1
log4j.appender.filer.layout=org.apache.log4j.PatternLayout
log4j.appender.filer.layout.ConversionPattern=%-5p [%t] %c.%M() - %m
(%rms)%n


log4j.appender.chainsaw=org.apache.log4j.net.SocketAppender
log4j.appender.chainsaw.RemoteHost=localhost
log4j.appender.chainsaw.Port=4445
log4j.appender.chainsaw.LocationInfo=true

#log4j.appender.dest1=org.apache.log4j.ConsoleAppender
#log4j.appender.dest1.layout=org.apache.log4j.PatternLayout
#log4j.appender.dest1.layout.ConversionPattern=%-5p [%t] %c - %m (%rms)


 

Note the fully qualified path here:
c:/webapps/IDM/WEB-INF/logs/output.log
 
That should change for your file to an appropriate value, and I'm fairly
certain this file should exist already (seems to me I had to create this
file before log4j would write to it)
 
If anyone can show me how to set this as a 'runtime' property (ie: from
a servlet context, determine the 'real path' to the WEB-INF/logs
directory  AND set it in log4j programmaticaly) I'd be much obliged.



> -----Original Message-----
> From: a b [mailto:[EMAIL PROTECTED] 
> Sent: Friday, June 20, 2003 3:15 PM
> To: [EMAIL PROTECTED]
> Subject: basic logging question
> 
> 
> Hello every one,
> I need to log messages using either tomcat logger or log4j. I 
> have added <Logger 
> className="org.apache.catalina.logger.FileLogger" 
> verbosity="1" prefix="localhost_gnomon_log." suffix=".txt" 
> timestamp="true"/> under the <Context> tag and 
> System.out.println("msg"); works and prints in the above 
> named file, but i want to use 
> the methods of org.apache.catalina.logger.FileLogger or 
> log4j's Logger class so that i can turn logging on and off 
> and can use various levels like debug,info,warn,errors etc. I 
> tried to import org.apache.catalina.logger.FileLogger in java 
> servlet, but it says class not found. I do have 
> commons-logging under <server-root>/common/lib folder. Please 
> guide me where am i going wrong? also if anyone who has log4j 
> under tomcat, i would appreciate their guidance in setting 
> log4j. i did create a example.cf file which created 
> configuration information for log4j and placed it under 
> WEB-INF/classes folder, but log4j does not picks the 
> configuration. Any ideas would be welcomed. Thanks
>  
> 
> 
> ---------------------------------
> Do you Yahoo!?
> SBC Yahoo! DSL - Now only $29.95 per month!
> 


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

Reply via email to