You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4net-user@logging.apache.org by Ofri Sela <of...@prolify.com> on 2006/01/04 10:52:51 UTC

Manipulating the configuration programmatically

Hi,

 

I would like to write a simple UI tool above the log4net configuration that
will basically allow me to control the level of logging per a given logger
or the root itself.

The thing is that I would like to allow this manipulation to take place
while my application is up and running. 

 

I'm aware that I can change the file itself and use the "ConfigureAndWatch"
API from my application but I wonder if there is a programmatic way to do it
as well. 

 

So if for example my configuration is as follows:

                        <root>

                                    <level value="WARN" />

                                    <appender-ref ref="MyDBAppender" />

                                    <appender-ref
ref="MyRollingFileAppender" />

                                    <appender-ref ref="MyAlertsAppender" />

                        </root>

                        <logger name="SomeLogger" additivity="false">

                                    <level value="ERROR" />

                                    <appender-ref ref="MyDBAppender" />

                                    <appender-ref
ref="MyRollingFileAppender" />

                                    <appender-ref ref="MyAlertsAppender" />

                        </logger>

 

 

I would like to be able to change the root level from "WARN" to "DEBUG" and
change the logger called "SomeLogger" level from "ERROR" to "INFO".

 

Please advice

 

 

 

 

Regards 

 

 

Ofri


Re: Manipulating the configuration programmatically

Posted by Matthew Brown <oc...@gmail.com>.
The programmatic way is to use ConfigureAndWatch, or set Watch=true in
your assembly attributes. Why bother to re-invent the wheel?


On 1/4/06, Ofri Sela <of...@prolify.com> wrote:
>
>
>
> Hi,
>
>
>
> I would like to write a simple UI tool above the log4net configuration that
> will basically allow me to control the level of logging per a given logger
> or the root itself.
>
> The thing is that I would like to allow this manipulation to take place
> while my application is up and running.
>
>
>
> I'm aware that I can change the file itself and use the "ConfigureAndWatch"
> API from my application but I wonder if there is a programmatic way to do it
> as well.
>
>
>
> So if for example my configuration is as follows:
>
>                         <root>
>
>                                     <level value="WARN" />
>
>                                     <appender-ref ref="MyDBAppender" />
>
>                                     <appender-ref
> ref="MyRollingFileAppender" />
>
>                                     <appender-ref ref="MyAlertsAppender" />
>
>                         </root>
>
>                         <logger name="SomeLogger" additivity="false">
>
>                                     <level value="ERROR" />
>
>                                     <appender-ref ref="MyDBAppender" />
>
>                                     <appender-ref
> ref="MyRollingFileAppender" />
>
>                                     <appender-ref ref="MyAlertsAppender" />
>
>                         </logger>
>
>
>
>
>
> I would like to be able to change the root level from "WARN" to "DEBUG" and
> change the logger called "SomeLogger" level from "ERROR" to "INFO".
>
>
>
> Please advice
>
>
>
>
>
>
>
>
>
> Regards
>
>
>
>
>
> Ofri