• 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:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Logging in Tomcat 5

 
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I'm working on Linux machine. hope this doesn't matter for this topic.

I've set up log4j in Tomcat 5.0.28 by copying the commons-jar & log4j.jar in commons lib folder and log4j.properties in common/classes folder.


With this i was able to send my logs to the file specified in the log4j.properties.

I want to know how can we implement the following things.

1. Want to separate only the stdout& errors from the log file to another, as of ow i'm getting messages of commongs logging and server stuff etc..etc...

2. How to do set up the loggin specific to myapplication. Not to the entire tomcat applications.
So that when i provide the .war file, logging jars and properties file also can be supplied to deploy along with the war.

Any help for this is appreciated.
Thank you very much in advance.



 
Saloon Keeper
Posts: 28654
211
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

uranch sushi wrote:Hi,

I'm working on Linux machine. hope this doesn't matter for this topic.

I've set up log4j in Tomcat 5.0.28 by copying the commons-jar & log4j.jar in commons lib folder and log4j.properties in common/classes folder.


With this i was able to send my logs to the file specified in the log4j.properties.

I want to know how can we implement the following things.

1. Want to separate only the stdout& errors from the log file to another, as of ow i'm getting messages of commongs logging and server stuff etc..etc...

2. How to do set up the loggin specific to myapplication. Not to the entire tomcat applications.
So that when i provide the .war file, logging jars and properties file also can be supplied to deploy along with the war.

Any help for this is appreciated.
Thank you very much in advance.





stdout and stderr aren't logfiles and you should NEVER use them in production apps. On Linux, they get squashed together and dumped to catalina.out, but they lack the amenities of true logfiles.

To configure log4j for a webapp, set up a log4j config file (properties or XML, as you like). This file goes into the WEB-INF/classes directory. If you want to do fixed configurations, hardcoding your logfile names and stuff, that's all you need. If you want to be able to override the configuration, you can create a small "null servlet" (just init(), no doGet()/doPost()) and programmatically configure log4j like the examples on the Log4 website show, placing the code in the null servlet's init() method. If you're REALLY ambitious, that code can pluck config out of the webapp context configuration using JNDI.

Complex projects often have multiple logging systems used by the different subsystems, so you might need to add a logging consolidator to ensure that they all get rerouted to log4J.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic