Struts comes with a marvellous package known as commons-logging - which is
what struts uses to output log messages.
Commons logging info may be found at:
http://jakarta.apache.org/commons/logging.html
Its not actually a logger itself, but rather an api that allows you to
change the logger you use without changing your code. (It does for logging
what jaxp does for xml parsing...).

Its easy to use - for example:
(I mean really really easy. It took me five minutes to work out how to use
it!)

Log log = LogFactory.getLog(this.getClass());
if(log.isInfoEnabled())
{
  log.info("My dog is inside the piano");
}

etc...

catch(StuckDogException ex)
{
  if(log.isErrorEnabled())
  {
    log.error("I think he is stuck in there",ex);
  }
}

Commons-logging will then use whatever logger you choose to output these to
the logs (Log4J is a very popular choice). Of course you have to have your
underlying logger set up properly (commons-logging doesnt cover the config
of your logger) , for that refer to instructions with your logger.

-----Original Message-----
From: Suresh Addagalla [mailto:[EMAIL PROTECTED]]
Sent: Monday, 27 January 2003 23:04
To: [EMAIL PROTECTED]
Subject: Logging


Hi,

Please don't mind if my question is simplistic, but it's an area not
explored by me.

I need to implement logging in my Struts application. For now, I want to
keep it very very simple, may be just limit to printing debug/info
statements. But I am sure that in future I would need to provide a
sophisticated logging (with different logging levels and formats). So,
how should I design my logging now so that I would be able to seamlessly
extend it in future? Even better, I should be able to make use of
already existing free & open source logging APIs/frameworks. Pls guide
me on this aspect.

Thanks,
Suresh



--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to