You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by Daniela Wersin <cl...@yahoo.de> on 2009/12/12 03:42:04 UTC
how to access and manipulate the log4j configuration programmatically
Hi all
is there a way to access and manipulate the log4j configuration programmatically from Java? For example, I would like to get all ConsoleAppenders and modify their ConversionPattern. I am aware that I could parse each line in the configuration file, or load the configuration into a Java Properties object and inspect each Property, but both these approaches are tedious and I wonder if there's a better way.
Thanks!
-- Daniela
__________________________________________________
Do You Yahoo!?
Sie sind Spam leid? Yahoo! Mail verfügt über einen herausragenden Schutz gegen Massenmails.
http://mail.yahoo.com
Re: how to access and manipulate the log4j configuration programmatically
Posted by Jacob Kjome <ho...@visi.com>.
Sure. You can query appenders from logger objects and manipulate everything
programatically. There used to be an application called LogWeb [1] that did this,
but seems to have fallen off the face of the earth. The code was licensed under
Apache2, if I recall correctly, so I would think it would still be available
somewhere?
In any case, there's a simple ConfigurationServlet [2] in the Log4j sandbox that
you can try to get started quickly.
[1] http://www.codeczar.com/projects/components/logweb/
[2]
http://svn.apache.org/repos/asf/logging/sandbox/log4j/log4j_sandbox/trunk/src/java/org/apache/log4j/servlet/ConfigurationServlet.java
Jake
On 12/11/2009 8:42 PM, Daniela Wersin wrote:
> Hi all
>
> is there a way to access and manipulate the log4j configuration programmatically from Java? For example, I would like to get all ConsoleAppenders and modify their ConversionPattern. I am aware that I could parse each line in the configuration file, or load the configuration into a Java Properties object and inspect each Property, but both these approaches are tedious and I wonder if there's a better way.
>
> Thanks!
> -- Daniela
>
>
> __________________________________________________
> Do You Yahoo!?
> Sie sind Spam leid? Yahoo! Mail verfügt über einen herausragenden Schutz gegen Massenmails.
> http://mail.yahoo.com
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org