List Info

Thread: Enable/Disable logging programatically.




Enable/Disable logging programatically.
user name
2006-07-19 16:58:09
[I responded to this a minute ago, accidentally prematurely
hit "send", sorry for the spam in my
signature on that one  ]

If you are using Log4j, you can easily change the root
logger level with:

org.apache.log4j.Logger.getRootLogger().setLevel(Level.DEBUG
);

The Level class has constants for log levels or static
methods to get log levels via strings. It
is pretty easy to configure log4j at runtime w/ finer
grained control, see the javadoc.

I tend to typically wire things up with a standard config
file in a default way that I want the
app to run (probably ERROR level) and then adjust things at
runtime as needed.

Hope this helps!

Rob



--- Albin Joseph <helloalbingmail.com> wrote:

> 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. 
> 
> Thanks
> Albin Joseph
> http://www.javacertifi
cate.net
> 
> 
> 
> 
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection
around 
http://mail.yahoo.com 


------------------------ Yahoo! Groups Sponsor
--------------------~--> 
See what's inside the new Yahoo! Groups email.
http://us.click.yahoo.com/2pRQfA/bOaOAA/yQLSAA/5cFolB/TM

------------------------------------------------------------
--------~-> 

 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://gr
oups.yahoo.com/group/chicago-java/

<*> To unsubscribe from this group, send an email to:
    chicago-java-unsubscribe@yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.c
om/info/terms/
 



Enable/Disable logging programatically.
user name
2006-07-20 03:22:57

Log4J also has a somewhat-beta JMX MBean that can be used in various ways to control the logging configuration. Last time I used it though, the interface was somewhat odd, even through jconsole.

 


From: chicago-java@yahoogroups.com [mailto:chicago-java@yahoogroups.com] On Behalf Of Rob Lambert
Sent: Wednesday, July 19, 2006 11:58 AM
To: chicago-java@yahoogroups.com
Subject: Re: [chicago-java] Enable/Disable logging programatically.

 

[I responded to this a minute ago, accidentally prematurely hit "send", sorry for the spam in my
signature on that one ]

If you are using Log4j, you can easily change the root logger level with:

org.apache.log4j.Logger.getRootLogger().setLevel(Level.DEBUG);

The Level class has constants for log levels or static methods to get log levels via strings. It
is pretty easy to configure log4j at runtime w/ finer grained control, see the javadoc.

I tend to typically wire things up with a standard config file in a default way that I want the
app to run (probably ERROR level) and then adjust things at runtime as needed.

Hope this helps!

Rob

--- Albin Joseph <helloalbingmail.com> wrote:

> hi experts
&gt;
> 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
&gt; from my program. Sometime I may require to turn on only DEBUG,
&gt; sometimes DEBUG and INFO may be required. How can I do that? Please
&gt; help me. Any help would be much valuable.
>
> Thanks
&gt; Albin Joseph
&gt; http://www.javacertificate.net
>
>
>
>
>

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

__._,_.___ __,_._,___
[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )