wood burning stoves 2.0*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes where did log file go? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "where did log file go?" Watch "where did log file go?" New topic
Author

where did log file go?

Jingh Yi
Ranch Hand

Joined: Mar 23, 2005
Posts: 90
Hi,

I tried to use log4j for logs. The following is my code:


How come after the servlet is invoked, no log file is generated. Also there is an error in stdout: log4j:WARN No appenders could be found for logger (c:/test.log).

How do I make it work?


Thanks,
Jenny
Mat Williams
Ranch Hand

Joined: Jul 20, 2005
Posts: 215
Hi,

Setting up log4j is a bit more complex than the example you have provided.
I suggest that you read this Log4j Short Manual. If you still need more then then post back and I (or someone else) can send you a short example. I don't have one here at the moment as I have just rebuilt the computer so I would need to spend the time to write one, so have a go first.

Mat
Mat Williams
Ranch Hand

Joined: Jul 20, 2005
Posts: 215
Hi,

Finished rebuilding the pc, so here is some code.

au.com.mattwill.listeners.WebAppContextListener.java


au.com.mattwill.servlets.HelloWorld.java


web.xml


log4j.properties


directory structure is
E:\Apache Software Foundation\Tomcat 5.0\ - this is where tomcat is installed (form heron I will call this $TomcatHome)
$TomcatHome\webapps\SCWCD\ - this is the webapp I am using (form heron I will call this $SCWCD)
$SCWCD\WEB-INF\clases\au\com\mattwill\listeners & $SCWCD\WEB-INF\clases\au\com\mattwill\servlets is where the classes are
web.xml in the normal place $SCWCD\WEB-INF\
(no suprises so far)

log4j.properties lives in $SCWCD\WEB-INF\

and the logfile produced is
E:/Apache Software Foundation/Tomcat 5.0/logs/scwcd.log

Hope this helps

Mat
Jingh Yi
Ranch Hand

Joined: Mar 23, 2005
Posts: 90
very very cool, Mat! It's now working. Thanks a lot!!!
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: where did log file go?