It is not necessary to use the DOMConfigurator (or any other
Configurator) to configure log4net. You can do all the configuration
programmatically.

To get a feel for what the configurators do have a look at the source
for the log4net.Config.BasicConfigurator. This shows how to create and
configure a ConsoleAppender and attach it to the log4net
ILoggerRepository, and it also shows how to lookup the correct
ILoggerRepository to use. The configurators use Inversion Of Control to
allow the ILoggerRepository implementation to handle the configuration
so you should look at the log4net.Repository.Hierarchy.Hierachy class at
the BasicRepositoryConfigure method.

Essentially all you need to do is to create the appenders
programmatically, configure them. Then lookup a logger from the
repository and attach the appender to the logger.

Cheers,
Nicko 

> -----Original Message-----
> From: Shaily Goel [mailto:[EMAIL PROTECTED] 
> Sent: 20 September 2004 09:48
> To: [email protected]
> Cc: [EMAIL PROTECTED]
> Subject: configuration of Log4Net Environment
> 
> Currently I am using a configuration file to configure 
> log4net environment..The format of this configuration file is 
> specified by Log4net which is mentioned below in mail
> 
> I am using DOMConfigurator.ConfigureAndWatch(FileInfo 
> ConfigFile) API to configure the envioronment
> 
> But Is it possible that i can configure various appenders and 
> initilize the log4net  environment myself without using this 
> configuration file or XmlBlob(DomConfigurator API)?
> 
> The idea is that  I want to initlize the log4net environment 
> and various appenders without using configuration file or 
> xmlBlob.If  I know the settings of various appenders which 
> needs to be applied then i should be able to apply those 
> settings directly to appenders and initilize them if they are 
> not or update the appender's settings if they are already 
> initlized .There should be no need of creating the xml file 
> or xmlBlob and then giving that XmlBlob to DomConfigurator 
> for configuring various appenders.Is it compulsary to use 
> DomConfigurator to configure log4net environment?What 
> DomConfigurator actually do?
> 
> 
> <?xml version="1.0" encoding="utf-8" standalone="yes"?> 
> <log4net debug="true">
>       <appender names="RollingFileAppender"
> type="log4net.Appender.RollingFileAppender">
>       <param name="File"
> value="/home/sgoyal/loggerframework/log4net/final/LocalLog.txt" />
>       <param name="appendToFile" value="true" />
>       <param name="maxSizeRollBackups" value="2" />
>       <param name="maximumFileSize" value="1MB" />
>       <layout type="Novell.Rce.logger.SimpleLayout, 
> LoggerModule.dll"> </layout>
>       </appender> 
> 
>       <!--Appender to log event into syslog-->
>       <appender name="SysLog" type="Novell.Rce.logger.SyslogAppender,
> LoggerModule.dll">
>         <param name="Facility" value="USER" />
>         <!--INFO & above will be logged to syslog Threshold 
> can be any one of debug, info, warn or error-->
>           <param name="Threshold" value="debug" />
>         <layout type="Novell.Rce.logger.SimpleLayout,
> LoggerModule.dll"> </layout>
>       </appender>
> 
>       <!--Appender to send event into Central Log Service-->
>       <appender name="CENTRAL_LOG"
> type="Novell.Rce.logger.CentralLogServiceAppender, LoggerModule.dll">
>         <!--specify the IP address or dns name of the machine where
> Central Log Service is hosted-->      
>         <param name="CentralServerAddress" value="164.99.149.177" /> 
>         <!--specify the port number on which Tomcat is listening-->
>         <param name="port" value="8080" /> 
>         <param name="reconnectionDelay" value="3000" /> 
>         <param name="maxQueueSize" value="2000" /> 
>         <param name="timeout" value="5000" /> 
>         <!--INFO & above will be sent to central log service.
> Threshold can be any one of debug,info, warn or error-->
>           <param name="Threshold" value="debug"/>
>       </appender>
> 
>       <!--This section is used to enable or disable the above 
> configured appenders
>           appender mentioned in this section only will be 
> loaded by Log4J.-->
>       <root> 
>            <appender-ref ref="CENTRAL_LOG"/>
>          <appender-ref ref="RollingFileAppender"/>
>            <appender-ref ref="SysLog"/>
>    
>          
>          <!-- uncomment the following line to enable 
> CentralLogServiceAppender, Before that make sure CentralLogService is
>               up-->
>          <!-- 
>          <appender-ref ref="SMTP"/> 
>          <appender-ref ref="RollingFileAppender"/>
>            <appender-ref ref="SysLog"/>
>          <appender-ref ref="CENTRAL_LOG"/>
>          <appender-ref ref="SysLog"/>
>          <appender-ref ref="CENTRAL_LOG"/>
>          -->  
>       </root> 
> </log4net>
> 
> 
> Thanks
> Shaily
> 
> 
> 

Reply via email to