Thanks 

I am building a Windows Application using Microsoft
Visual Basic 2005 Beta 2.

In my app.config file I have put
<log4net>
                <appender name="RollingLogFileAppender"
type="log4net.Appender.RollingFileAppender">
                        <file value="c:\log4net.log"/>
                        <appendToFile value="true"/>
                        <rollingStyle value="Date"/>
                        <datePattern value="yyyyMMdd"/>
                        <lockingModel
type="log4net.Appender.RollingFileAppender+MinimalLock"/>
                        <layout type="log4net.Layout.PatternLayout">
                                <conversionPattern
value="%date|[%thread]|%-5level|%logger|%property{NDC}|%message%newline"/>
                        </layout>
                </appender>

                <root>
                        <level value="INFO"/>
                        <level value="DEBUG"/>
                        <appender-ref ref="RollingLogFileAppender"/>
                </root>
        </log4net>

The sample application code in which I am trying to
write log for a button click with time of clicking is:

Public Class Form1
'Declaration part   
    Private Shared ReadOnly logger As log4net.ILog =
log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType)

    Private Sub Form1_Load(ByVal sender As Object,
ByVal e As System.EventArgs) Handles Me.Load
        log4net.Config.XmlConfigurator.Configure()
'Initialize log4net ---> here it generates exception
    End Sub

    Private Sub Button1_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
Button1.Click
'trying to write in log
        log4net.NDC.Push("Form1.vb")
        logger.Info("Button1 Clicked at :" & Now)
        log4net.NDC.Pop()
    End Sub
End Class


--- Nicko Cadell <[EMAIL PROTECTED]> wrote:

> What type of application are you building? From the
> look of the call
> stack it looks like some kind of VS add-in. If so
> which version of VS?
> I can't reproduce this with a simple forms app so it
> may be some
> interaction with the hosting process.
> 
> Is it possible for you to post the source to a bare
> bones version of
> your app? Just something that it launched in the
> same way, has a form
> which is displayed, and calls
> XmlConfigurator.Configure from the OnLoad
> method. If I can reproduce the problem it is much
> easier to fix.
> 
> Cheers,
> Nicko
> 
> > -----Original Message-----
> > From: depsi programmer
> [mailto:[EMAIL PROTECTED] 
> > Sent: 04 October 2005 05:40
> > To: Log4NET User
> > Subject: TypeInitializationException was unhandled
> > 
> > Hi
> > 
> > I am getting following error in log4.net
> > 
> > The exact error message and stack trace:
> > 
> > System.TypeInitializationException was unhandled
> > 
> >  Message="The type initializer for
> > 'log4net.Core.LoggerManager' threw an exception."
> > 
> >  Source="log4net"
> > 
> >  TypeName="log4net.Core.LoggerManager"
> > 
> >  StackTrace:
> > 
> >       at
> > log4net.Core.LoggerManager.GetRepository(Assembly
> > repositoryAssembly)
> > 
> >       at log4net.LogManager.GetRepository(Assembly
> > repositoryAssembly)
> > 
> >       at
> log4net.Config.XmlConfigurator.Configure()
> >      
> >       at
> System.Windows.Forms.Form.OnLoad(EventArgs e)
> > 
> >       at
> System.Windows.Forms.Form.OnCreateControl()
> > 
> >       at
> > System.Windows.Forms.Control.CreateControl(Boolean
> > fIgnoreVisible)
> > 
> >       at
> System.Windows.Forms.Control.CreateControl()
> > 
> >       at
> > System.Windows.Forms.Control.WmShowWindow(Message&
> m)
> > 
> >       at
> System.Windows.Forms.Control.WndProc(Message&
> > m)
> > 
> >       at
> >
>
System.Windows.Forms.ScrollableControl.WndProc(Message&
> > m)
> > 
> >       at
> >
>
System.Windows.Forms.ContainerControl.WndProc(Message&
> > m)
> > 
> >       at
> > System.Windows.Forms.Form.WmShowWindow(Message& m)
> > 
> >       at
> System.Windows.Forms.Form.WndProc(Message& m)
> > 
> >       at
> >
>
System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message&
> > m)
> > 
> >       at
> >
>
System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message&
> > m)
> > 
> >       at
> >
>
System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr
> > hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
> > 
> >       at
> >
>
System.Windows.Forms.UnsafeNativeMethods.SendMessage(HandleRef
> > hWnd, Int32 msg, Int32 wParam, Int32 lParam)
> > 
> >       at
> > System.Windows.Forms.Form.SetVisibleCore(Boolean
> > value)
> > 
> >       at
> > System.Windows.Forms.Control.set_Visible(Boolean
> > value)
> > 
> >       at
> >
>
System.Windows.Forms.Application.ThreadContext.RunMessageLoopI
> > nner(Int32
> > reason, ApplicationContext context)
> > 
> >       at
> >
>
System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32
> > reason, ApplicationContext context)
> > 
> >       at System.Windows.Forms.Application.Run(Form
> > mainForm)
> > 
> >       at
> System.AppDomain.nExecuteAssembly(Assembly
> > assembly, String[] args)
> > 
> >       at System.AppDomain.ExecuteAssembly(String
> > assemblyFile, Evidence assemblySecurity, String[]
> > args)
> > 
> >       at
> >
>
Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
> > 
> >       at
> >
>
System.Threading.ThreadHelper.ThreadStart_Context(Object
> > state)
> > 
> >       at
> >
>
System.Threading.ExecutionContext.Run(ExecutionContext
> > executionContext, ContextCallback callback, Object
> > state)
> > 
> >       at
> System.Threading.ThreadHelper.ThreadStart() 
> > 
> > When I checked the inner exception it was 
> > 
> > The inner exception is
> > The type initializer for
> 'log4net.Core.LoggerManager'
> > threw an exception.
> > Stack Trace is
> >   at
> log4net.Core.LoggerManager.GetRepository(Assembly
> > repositoryAssembly)
> >   at log4net.LogManager.GetRepository(Assembly
> > repositoryAssembly)
> >   at log4net.Config.XmlConfigurator.Configure()
> >   at xyz.FrmMain.Form1_Load(Object sender,
> EventArgs
> > e) in xyz.vb:line 147
> >   at System.Windows.Forms.Form.OnLoad(EventArgs e)
> >   at System.Windows.Forms.Form.OnCreateControl()
> >   at
> > System.Windows.Forms.Control.CreateControl(Boolean
> > fIgnoreVisible)
> >   at System.Windows.Forms.Control.CreateControl()
> >   at
> > System.Windows.Forms.Control.WmShowWindow(Message&
> m)
> >   at System.Windows.Forms.Control.WndProc(Message&
> m)
> >   at
> >
>
System.Windows.Forms.ScrollableControl.WndProc(Message&
> > m)
> >   at
> >
>
System.Windows.Forms.ContainerControl.WndProc(Message&
> > m)
> >   at
> System.Windows.Forms.Form.WmShowWindow(Message&
> > m)
> >   at System.Windows.Forms.Form.WndProc(Message& m)
> >   at
> >
>
System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message&
> 
=== message truncated ===



                
__________________________________ 
Yahoo! Music Unlimited 
Access over 1 million songs. Try it free.
http://music.yahoo.com/unlimited/

Reply via email to