Title: RE: Multithreading and using FileAppender

I am so stupid! I forgot to call t.Start(). Your suggestion to call t.Join() made that clear to me. It's working perfectly now.

I am so sorry for wasting your time like this.

Erik

-----Original Message-----
From: Nicko Cadell [mailto:[EMAIL PROTECTED]]
Sent: Friday, January 07, 2005 2:33 PM
To: Log4NET User
Subject: RE: Multithreading and using FileAppender


Erik,

Are you calling t.Join() after starting the thread? If not then the application may be exiting before the thread has been run.

Nicko

> -----Original Message-----
> From: Burger, Erik [mailto:[EMAIL PROTECTED]]
> Sent: 07 January 2005 14:08
> To: 'Log4NET User'
> Subject: RE: Multithreading and using FileAppender
>
> Nicko,
>
> I enabled internal debug, then ran the code twice. Once using
> a direct call to c.Loop() in my Main (so I simply replaced
> 'Thread t = new Thread( new ThreadStart( c.Loop ));' with
> 'c.Loop()', then again using the thread. There is no
> difference in the debug output from log4net.
>
> In the first run (no threading), the log file contains both
> the Log.Debug() call I make on application start (I added it
> as you suggested) as the Log.Info call I make in c.Loop().
>
> In the second run (threading), the log file contains only the
> Log.Debug call I make on application start.
>
> I am using the assembly attribute to configure log4net, and
> put them in my AssemblyInfo.cs.
>
> I also added a ConsoleAppender to my config file to see
> whether the problem lies in the FileAppender, as follows:
>                 <appender name="ConsoleAppender"
> type="log4net.Appender.ConsoleAppender">
>                         <target value="Console.Error" />
>                         <layout type="log4net.Layout.PatternLayout">
>                                 <conversionPattern value="%d
> [%t] %-5p %c [%x] - %m%n"  />
>                         </layout>
>                 </appender>
>
> The behaviour is identical. In the first run both entries are
> made in the console, on the second run only the first.
>
> Would it be useful to send the debug output I get from
> log4net? It's quite lengthy so I figured I'd ask first.
>
> Thanks for your time,
> Erik
>
> -----Original Message-----
> From: Nicko Cadell [mailto:[EMAIL PROTECTED]]
> Sent: Friday, January 07, 2005 1:18 PM
> To: Log4NET User
> Subject: RE: Multithreading and using FileAppender
>
>
> Eric,
>
> If you enable internal debug you should get more details on
> what log4net is trying to do.
> http://logging.apache.org/log4net/release/manual/faq.html#inte
> rnalDebug
>
> How have you configured log4net? Using the assembly attribute
> or by calling the Configure method directly? Also can you try
> logging a message on application start, i.e. before you
> create the thread.
>
> Nicko
>
> > -----Original Message-----
> > From: Burger, Erik [mailto:[EMAIL PROTECTED]]
> > Sent: 06 January 2005 17:47
> > To: '[email protected]'
> > Subject: Multithreading and using FileAppender
> >
> > I have a console application that calls a function within a class
> > (provided in a separate dll) from within a thread as follows:
> >
> > Class1 c = new Class1();
> > Thread t = new Thread( new ThreadStart( c.Loop ));
> >
> > The Class1.Loop() function is defined as follows:
> >
> > public void Loop()
> > {
> >         log.Info( "Info" );                    
> > }
> >
> > My config file is shown below.
> >
> > <?xml version="1.0" encoding="utf-8" ?> <configuration>
> >         <configSections>
> >                 <section name="log4net"
> > type="log4net.Config.Log4NetConfigurationSectionHandler,
> log4net" />
> >         </configSections>
> >         <log4net>
> > <appender name="RollingLogFileAppender"
> > type="log4net.Appender.RollingFileAppender">
> >         <file value="logfile.log" />
> >         <appendToFile value="true" />
> >         <datePattern value="yyyyMMdd" />
> >         <rollingStyle value="Date" />
> >         <layout type="log4net.Layout.PatternLayout">
> >                 <conversionPattern value="%d [%t] %-5p %c
> [%x] - %m%n"
> > />
> >         </layout>
> > </appender>
> >                 <root>
> >                         <level value="DEBUG" />
> >                         <appender-ref
> ref="RollingLogFileAppender" />
> >                 </root>
> >         </log4net>
> > </configuration>
> >
> > I'm using the following attribute in my AssemblyInfo.cs:
> > [assembly: log4net.Config.DOMConfigurator(Watch=true)]
> >
> > When I run the application, the logfile is created but nothing is
> > written! What can be happening?
> >
> > Thanks,
> > Erik
> >
> >
> > The information transmitted by this e-mail message is
> intended solely
> > for the use of the person to whom or entity to which it is
> addressed.
> > The message may contain information that is privileged and
> > confidential.  Disclosure, dissemination, distribution, review,
> > retransmission to, other use of or taking any action in
> reliance upon
> > this information by anyone other than the intended recipient is
> > prohibited. If you are not the intended recipient, please do not
> > disseminate, distribute or copy this communication, by e-mail or
> > otherwise. Instead, please notify us immediately by return e-mail
> > (including the original message with your reply) and then
> delete and
> > discard all copies of the message.
> >
> > Although we have taken precautions to minimize the risk of
> > transmitting viruses we nevertheless advise you to carry
> out your own
> > virus checks on any attachment to this message. We accept
> no liability
> > for any loss or damage caused by viruses.
> >
> >
>
> The information transmitted by this e-mail message is
> intended solely for the use of the person to whom or entity
> to which it is addressed. The message may contain information
> that is privileged and confidential.  Disclosure,
> dissemination, distribution, review, retransmission to, other
> use of or taking any action in reliance upon this information
> by anyone other than the intended recipient is prohibited. If
> you are not the intended recipient, please do not
> disseminate, distribute or copy this communication, by e-mail
> or otherwise. Instead, please notify us immediately by return
> e-mail (including the original message with your reply) and
> then delete and discard all copies of the message.
>
> Although we have taken precautions to minimize the risk of
> transmitting viruses we nevertheless advise you to carry out
> your own virus checks on any attachment to this message. We
> accept no liability for any loss or damage caused by viruses.
>
>

The information transmitted by this e-mail message is intended solely for the use of the person to whom or entity to which it is addressed. The message may contain information that is privileged and confidential.  Disclosure, dissemination, distribution, review, retransmission to, other use of or taking any action in reliance upon this information by anyone other than the intended recipient is prohibited. If you are not the intended recipient, please do not disseminate, distribute or copy this communication, by e-mail or otherwise. Instead, please notify us immediately by return e-mail (including the original message with your reply) and then delete and discard all copies of the message.

Although we have taken precautions to minimize the risk of transmitting viruses we nevertheless advise you to carry out your own virus checks on any attachment to this message. We accept no liability for any loss or damage caused by viruses.

Reply via email to