This week's book giveaway is in the Beginning Java forum.
We're giving away four copies of Get Programming with Java (MEAP only) and have Peggy Fisher on-line!
See this thread for details.
Win a copy of Get Programming with Java (MEAP only) this week in the Beginning Java 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Bear Bibeault
  • Knute Snortum
  • Liutauras Vilda
Sheriffs:
  • Tim Cooke
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Ron McLeod
  • Ganesh Patekar
  • salvin francis
Bartenders:
  • Tim Holloway
  • Carey Brown
  • Stephan van Hulst

Logging info on server side  RSS feed

 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does any one know how I can log to the tomcat server logs via a class not extending HTTPServlet on the server side. Basically a class used by a servlet. In the servlet I simply use log(" mesg"). How can I pass this ability to another class?

Thanks
 
Ranch Hand
Posts: 1183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why would you want to log something that has already been logged ?
 
Marshal
Posts: 67200
169
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use Log4J.
 
Bartender
Posts: 6663
5
Firefox Browser Linux MyEclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are many logging frameworks out there that can do it for you. Have a look at log4j like Bear suggested
 
Fabio Piergentili
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
log4j worked great. For anyone else interested, this is all I had to do:

1. put log4j jar file in lib directory of tomcat
2. provide a log4j.properties file located in the tomcat lib directory to set up logging to a file instead of console ( I have no idea where the console stuff would go as this is getting run from the tomcat container )
3. in the class provide ( In my case the class is QueryBuilder )

 
Ranch Hand
Posts: 650
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Fabio Piergentili wrote:2. provide a log4j.properties file located in the tomcat lib directory to set up logging to a file instead of console ( I have no idea where the console stuff would go as this is getting run from the tomcat container )
[/code]



The console is the window in which the user launched the server. If you're running as a system service, then I think you don't have a console (at least on Windows).

 
Bear Bibeault
Marshal
Posts: 67200
169
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's a Windows-only situation. On other OS's, console is the catalina.out file in the logs folder.
 
Fabio Piergentili
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are correct. Now I do not have to track another file. I just log to console and it dumps into catalina.out file in the tomcat logs directory.

Thanks for the info.
 
He baked a muffin that stole my car! And this tiny ad:
Programmatically Create PDF Using Free Spire.PDF with Java
https://coderanch.com/wiki/703735/Programmatically-Create-PDF-Free-Spire
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!