Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Simple way to log servlet in tomcat  RSS feed

 
Ali Gordon
Ranch Hand
Posts: 182
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ali Gordon
Ranch Hand
Posts: 182
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65830
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Then stop using eclipse as your run-time environment. Run Tomcat standalone and you'll be much happier.
 
Ali Gordon
Ranch Hand
Posts: 182
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Kesava Krishna
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ali Gordon
Ranch Hand
Posts: 182
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ?
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So your original problem is solved?
 
Ali Gordon
Ranch Hand
Posts: 182
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!