Gee thanks Ron!

Its working absolutely fine now...
All i needed to do was add the XMLConfigureAndWatch method call...

All the other stuff was preety much in place.

Thanks,
Piyush

On 9/9/05, Ron Grabowski <[EMAIL PROTECTED]> wrote:
> I think more people could help you if you post questions like this to
> the log4net-user list.
> 
> --- Piyush Arya <[EMAIL PROTECTED]> wrote:
> 
> > Issue: My log4net configuration needs to be specified in a config
> > other than my app.config. This, however is not happening.
> 
>  log4net.Config.XmlConfigurator.ConfigureAndWatch( _
>  New FileInfo( _
>   AppDomain.CurrentDomain.SetupInformation.ApplicationBase + _
>   "log4net.config"))
> 
> Since you're using a windows app, the log4net.config file needs to be
> placed in the same directory where the .EXE file is launched from.
> 
> > Description: I had earlier put in my config in the App.Config. This
> > is
> > not being read at all, apparently due to some appsettings parameters.
> 
> Did you remember to add a configSection node in your App.Config so it
> knows about log4net?
> 
> <configuration>
>  <configSections>
>  <section name="log4net"
> type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
>  </configSections>
>  <appSettings>
>  <add key="log4net.Internal.Debug" value="true" />
>  </appSettings>
>  <log4net>
>  ...
>  </log4net>
> </configuration>
> 
> > Query: Is there anything specific I need to do to enable this?
> > If not, then I'd like to move my configuration in some logging.config
> > file. However, I have been unable to find in the documentation on how
> > to actually set the file path and where to set it in the code.
> > Would we need to do this in every function where we are using the
> > log.debug etc methods?
> > http://logging.apache.org/log4net/release/manual/configuration.html
> > This link states that we can do it. But I'm stuck up on where to do
> > this sort of stuff.
> 
> Its more common for people to use the XmlConfigurator rather than the
> BasicConfigurator:
> 
> http://tinyurl.com/8bqlm
> http://logging.apache.org/log4net/release/sdk/log4net.Config.XmlConfigurator.Configure_overloads.html
> 
> > Code:
> > Imports log4net
> > Imports log4net.Appender
> > Imports log4net.Config
> > Public Class Logger
> > Dim loggerError As log4net.ILog = LogManager.GetLogger("LogError")
> > Private Sub logError(ByVal strMsg As String, ByVal e As
> > System.Exception)
> > If loggerError.IsErrorEnabled Then
> > loggerError.Error("[" + DateTime.Now.ToString() + "] " +
> > extractInfo(strMsg), e)
> > End If
> > End Sub
> > End Class
> 
> I don't know how familiar you are with the logging, but most people put
> a line like this at the beginning of each class they use the logger in:
> 
> Private Shared ReadOnly log As ILog =
> LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType)
> 
> What does the extractInfo function do?
> 
> > Config:
> > <appender name="ErrorRollingFileAppender"
> 
> I would start out with a very simple log4net config file:
> 
>  <log4net>
>  <appender name="FileAppender" type="log4net.Appender.FileAppender">
>   <file value="log.txt" />
>   <layout type="log4net.Layout.SimplyLayout" />
>  </appender>
>  <root>
>   <appender-ref ref="FileAppender" />
>  </root>
>  </log4net>
> 
> Then add to it once you know its working.
>

Reply via email to