• 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
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • Devaka Cooray
Saloon Keepers:
  • Ganesh Patekar
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • salvin francis
Bartenders:
  • Ron McLeod
  • Frits Walraven
  • Pete Letkeman

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 ?
 
Author and ninkuma
Marshal
Posts: 66820
168
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
Author and ninkuma
Marshal
Posts: 66820
168
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.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!