Win a copy of TDD for a Shopping Website LiveProject this week in the Testing forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Simple way to log servlet in tomcat

 
Ranch Hand
Posts: 182
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Rancher
Posts: 43027
76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 67637
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 43027
76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So your original problem is solved?
 
Ali Gordon
Ranch Hand
Posts: 182
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 43027
76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
You had your fun. Now it's time to go to jail. Thanks for your help tiny ad.
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic