Re: Enable/Disable logging programatically.
Nic James Ferrier <[email protected]> Thu, 20 Jul 2006 09:47:07 +0100
| Newsgroups | gmane.comp.java.advanced-servlets |
|---|---|
| Message-ID | <[email protected]> |
"Albin Joseph" <[email protected]> writes: > hi experts > > I want to configure Log4J or J2SE 1.4 logging programmatically. I > don't want to use any configuration files for configuring Log4J /J2SE > 1.4 logging . I want to enable/disable logging facility at runtime > from my program. Sometime I may require to turn on only DEBUG, > sometimes DEBUG and INFO may be required. How can I do that? Please > help me. Any help would be much valuable. Simply get a handle to the Logger and change it with logging API method calls. There is a big catch - normally you define Loggers statically, per class. Something like this: public class ServletDooDah extends .... { final static Logger LOGGER = Logger....; But if you're trying to alter them on the fly in your code that will clearly not be thread safe. So you're best bet is to create a per-request logger based on the class logger and then alter that from your servlet. -- Nic Ferrier http://www.tapsellferrier.co.uk for all your tapsell ferrier needs ------------------------ Yahoo! Groups Sponsor --------------------~--> Something is new at Yahoo! Groups. Check out the enhanced email design. http://us.click.yahoo.com/SISQkA/gOaOAA/yQLSAA/saFolB/TM --------------------------------------------------------------------~-> Before posting a question, try to find your answer here: <http://www.egroups.com/links/advanced-servlets> Announcements should go to: [email protected] To Post a message, send it to: [email protected] To Unsubscribe, send a blank message to: [email protected] Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/advanced-servlets/ <*> To unsubscribe from this group, send an email to: [email protected] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/