Forums Register Login

Simple way to log servlet in tomcat

+Pie Number of slices to send: Send
I have great difficulty in learning servlet filters from a book. I have a line of code -

This line is supposed to keep a track of users who requested for resources (i.e jsp, html, servlet) for updating their account information.

Please tell me where this information is logged.

What I tried so far -

I did not know where this information is actually logged. I thought that it was logged inside tomcat logs folder, so I created a log file and saw that nothing happened to it even after logging into the app and out of it. I used the post - https://stackoverflow.com/questions/2233053/where-can-i-view-tomcat-log-files-in-eclipse

Then, I looked at API for ServletContext#log() and googled tomcat servlet log and got this post - http://stackoverflow.com/questions/3154358/tomcat-servlet-logging
They used log4j, but my book does not mention anything about log4j, so I don't want to use it for now.
+Pie Number of slices to send: Send
ServletContext.log output should go into one of the log files in TOMCAT_HOME/logs, most likely catalina.out. You should not create any log files, that's done automatically.
+Pie Number of slices to send: Send
 

Ulf Dittmer wrote:ServletContext.log output should go into one of the log files in TOMCAT_HOME/logs, most likely catalina.out. You should not create any log files, that's done automatically.


Inside eclipse, I don't see catalina.out for my tomcat server. I only see catalina.policy, catalina.properties, server.xml, tomcat-users.xml etc.
Please help me to understand this.
1
+Pie Number of slices to send: Send
Then stop using eclipse as your run-time environment. Run Tomcat standalone and you'll be much happier.
+Pie Number of slices to send: Send
 

Bear Bibeault wrote:Then stop using eclipse as your run-time environment. Run Tomcat standalone and you'll be much happier.



Yes, I guess I'll just use eclipse to automate the creation of basic project files and move those manually to tomcat and run manually. It will save
me a world of pain.
+Pie Number of slices to send: Send
In ecllipse try to check in the console. Windows --> Show View --> Console. Try open this view and then run the tomcat and see if the catalina.out log is rolling the console.
+Pie Number of slices to send: Send
 

Kesava Krishna wrote:In ecllipse try to check in the console. Windows --> Show View --> Console. Try open this view and then run the tomcat and see if the catalina.out log is rolling the console.



Yes it is. What do you suggest I do ?
+Pie Number of slices to send: Send
So your original problem is solved?
+Pie Number of slices to send: Send
 

Ulf Dittmer wrote:So your original problem is solved?



Not really. I used a workaround - log to console. I'll get my web app, jsp, servlet basics right first and then I will learn logging and tomcat in detail.
+Pie Number of slices to send: Send
How is that a workaround? That's what happens if you run Tomcat in an IDE. If you want logging to a file, run it standalone.
I am going to test your electrical conductivity with this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 1021 times.
Similar Threads
Adding Date & time Stamp in Log file name
Log4j insn't creating logs for jforum
Problem configuring Hibernate and JPA in Eclipse
WAS 5.0 - Exception Stack Trace not printed in log file
Start Tomcat 7 as tomcat user (not root user)
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 19, 2024 01:08:56.