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 Cícero Raupp Rolim <ir...@gmail.com> on 2008/02/22 18:36:09 UTC

Problem CF + RollingFileAppender + Flush

Hi!

We are developing an application for compact .NET framework 2.0. We need log
events and view and real time. We configured the app.config file like
presented below:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <log4net>
    <appender name="RollingFileAppender" type="
log4net.Appender.RollingFileAppender">
      <file value="test.txt" />
      <appendToFile value="true" />
      <maxSizeRollBackups value="5" />
      <maximumFileSize value="100KB" />
      <rollingStyle value="Size" />
      <staticLogFileName value="true" />
      <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="%date [%thread] %-5level %logger [%ndc] -
%message%newline" />
      </layout>
    </appender>
    <root>
      <level value="ALL" />
      <appender-ref ref="RollingFileAppender" />
    </root>
  </log4net>
</configuration>

After log some events, the file "test.txt" continues with 0 size. We need
execute method LogManager.Shutdown() to save file with these events. Are
there one way to log events in real time without execute LogManager.Shutdown
()?

Thank's! Sorry for my poor English.

RE: Problem CF + RollingFileAppender + Flush

Posted by Morten Andersen <mo...@vianett.no>.
Hi

Maybe it is possible to set the buffer timeout value so that the buffer will be written to the file every x second even if the buffer size is not reached?

Morten

Fra: Price, Randall [mailto:randallp@vt.edu]
Sendt: 22. februar 2008 20:59
Til: Log4NET User
Emne: RE: Problem CF + RollingFileAppender + Flush

I am also using the RollingFileAppender without the <bufferSize value="0"> but do not have this problem.

My logs are written out almost immediately as they happen.  Maybe there some other way to flush them
Immediately as Cicero suggests below, but I am not doing anything special to make it happen.

Sorry I could not be of more help.


Here is my log4net.config file:

<?xml version="1.0" encoding="utf-8" ?>
<log4net>
  <appender name="RollingFile" type="log4net.Appender.RollingFileAppender">
    <file               value="logs\MyApplication.log"/>
    <appendToFile       value="true" />
    <maximumFileSize    value="2048KB" />
    <maxSizeRollBackups value="-1" />
    <countDirection     value="1" />
    <lockingModel       type="log4net.Appender.FileAppender+MinimalLock" />
    <layout type="log4net.Layout.PatternLayout">
      <conversionPattern value="%date [%thread] %-5level %logger - %message%newline" />
    </layout>
  </appender>

  <root>
    <!-- Levels  (from lowest to highest):  ALL | DEBUG | INFO | WARN | ERROR | FATAL | OFF | -->
    <level value="INFO" />
    <appender-ref ref="RollingFile" />
  </root>
</log4net>

Randall Price

Secure Enterprise Technology Initiatives
Microsoft Implementation Group
Virginia Tech Information Technology
1700 Pratt Drive
Blacksburg, VA  24060


From: Lee, Matthew [mailto:mlee@fhlbdm.com]
Sent: Friday, February 22, 2008 12:57 PM
To: Log4NET User
Subject: RE: Problem CF + RollingFileAppender + Flush

Let me clarify my response.  I had a similar challenge with the AdoNetAppender, which I fixed with the following configuration:

  <appender name="AdoNetAppender" type="log4net.Appender.AdoNetAppender">
    <bufferSize value="0" />
    ....
  </appender>

This resulted in records being written out immediately.  I was hoping you could do something similar with your appender.  As far as a "flush" command, I'm not sure.  I'll leave that to more knowledgeable people on the list.

Thanks,

Matt

________________________________
From: Cícero Raupp Rolim [mailto:ironworld@gmail.com]
Sent: Friday, February 22, 2008 11:49 AM
To: Log4NET User
Subject: Re: Problem CF + RollingFileAppender + Flush
Hi Matthew!

I trying to read the content of last file of RollingAppender, but this file keep "0" size until next file be created. I think that if we call one method to flush data into file is one way to solve problem. Does log4net have one method to flush information to FileAppender without call LogManager.ShutDown()?

Thanks!

Cícero
On Fri, Feb 22, 2008 at 2:38 PM, Lee, Matthew <ml...@fhlbdm.com>> wrote:
Does it help to set the buffer size to zero in the log4net configuration?

Thanks,

Matt

________________________________
From: Cícero Raupp Rolim [mailto:ironworld@gmail.com<ma...@gmail.com>]
Sent: Friday, February 22, 2008 11:36 AM
To: log4net-user@logging.apache.org<ma...@logging.apache.org>
Subject: Problem CF + RollingFileAppender + Flush
Hi!

We are developing an application for compact .NET framework 2.0. We need log events and view and real time. We configured the app.config file like presented below:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <log4net>
    <appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender">
      <file value="test.txt" />
      <appendToFile value="true" />
      <maxSizeRollBackups value="5" />
      <maximumFileSize value="100KB" />
      <rollingStyle value="Size" />
      <staticLogFileName value="true" />
      <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="%date [%thread] %-5level %logger [%ndc] - %message%newline" />
      </layout>
    </appender>
    <root>
      <level value="ALL" />
      <appender-ref ref="RollingFileAppender" />
    </root>
  </log4net>
</configuration>

After log some events, the file "test.txt" continues with 0 size. We need execute method LogManager.Shutdown() to save file with these events. Are there one way to log events in real time without execute LogManager.Shutdown()?

Thank's! Sorry for my poor English.

This message and any files transmitted with it are confidential and are intended solely for the use of the individual or entity to whom they are addressed.  If you have received this email in error, please delete the email and any files transmitted with it entirely from your computer.




This message and any files transmitted with it are confidential and are intended solely for the use of the individual or entity to whom they are addressed.  If you have received this email in error, please delete the email and any files transmitted with it entirely from your computer.



RE: Problem CF + RollingFileAppender + Flush

Posted by "Price, Randall" <ra...@vt.edu>.
I am also using the RollingFileAppender without the <bufferSize value="0"> but do not have this problem.

 

My logs are written out almost immediately as they happen.  Maybe there some other way to flush them

Immediately as Cicero suggests below, but I am not doing anything special to make it happen.

 

Sorry I could not be of more help.

 

 

Here is my log4net.config file:

 

<?xml version="1.0" encoding="utf-8" ?>

<log4net>

  <appender name="RollingFile" type="log4net.Appender.RollingFileAppender">

    <file               value="logs\MyApplication.log"/>

    <appendToFile       value="true" />

    <maximumFileSize    value="2048KB" />

    <maxSizeRollBackups value="-1" />

    <countDirection     value="1" />

    <lockingModel       type="log4net.Appender.FileAppender+MinimalLock" />

    <layout type="log4net.Layout.PatternLayout">

      <conversionPattern value="%date [%thread] %-5level %logger - %message%newline" />

    </layout>

  </appender>

 

  <root>

    <!-- Levels  (from lowest to highest):  ALL | DEBUG | INFO | WARN | ERROR | FATAL | OFF | -->

    <level value="INFO" />

    <appender-ref ref="RollingFile" />

  </root>

</log4net>

 

Randall Price

 

Secure Enterprise Technology Initiatives

Microsoft Implementation Group

Virginia Tech Information Technology

1700 Pratt Drive

Blacksburg, VA  24060

 

 

From: Lee, Matthew [mailto:mlee@fhlbdm.com] 
Sent: Friday, February 22, 2008 12:57 PM
To: Log4NET User
Subject: RE: Problem CF + RollingFileAppender + Flush

 

Let me clarify my response.  I had a similar challenge with the AdoNetAppender, which I fixed with the following configuration:

 

  <appender name="AdoNetAppender" type="log4net.Appender.AdoNetAppender">
    <bufferSize value="0" />

    ....

  </appender>

 

This resulted in records being written out immediately.  I was hoping you could do something similar with your appender.  As far as a "flush" command, I'm not sure.  I'll leave that to more knowledgeable people on the list.

 

Thanks,

 

Matt

 

________________________________

From: Cícero Raupp Rolim [mailto:ironworld@gmail.com] 
Sent: Friday, February 22, 2008 11:49 AM
To: Log4NET User
Subject: Re: Problem CF + RollingFileAppender + Flush

Hi Matthew!

I trying to read the content of last file of RollingAppender, but this file keep "0" size until next file be created. I think that if we call one method to flush data into file is one way to solve problem. Does log4net have one method to flush information to FileAppender without call LogManager.ShutDown()?

Thanks!

Cícero

On Fri, Feb 22, 2008 at 2:38 PM, Lee, Matthew <ml...@fhlbdm.com> wrote:

Does it help to set the buffer size to zero in the log4net configuration?

 

Thanks,

 

Matt

 

________________________________

From: Cícero Raupp Rolim [mailto:ironworld@gmail.com] 
Sent: Friday, February 22, 2008 11:36 AM
To: log4net-user@logging.apache.org
Subject: Problem CF + RollingFileAppender + Flush

Hi!

We are developing an application for compact .NET framework 2.0. We need log events and view and real time. We configured the app.config file like presented below:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <log4net>
    <appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender">
      <file value="test.txt" />
      <appendToFile value="true" />
      <maxSizeRollBackups value="5" />
      <maximumFileSize value="100KB" />
      <rollingStyle value="Size" />
      <staticLogFileName value="true" />
      <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="%date [%thread] %-5level %logger [%ndc] - %message%newline" />
      </layout>
    </appender>
    <root>
      <level value="ALL" />
      <appender-ref ref="RollingFileAppender" />
    </root>
  </log4net>
</configuration>

After log some events, the file "test.txt" continues with 0 size. We need execute method LogManager.Shutdown() to save file with these events. Are there one way to log events in real time without execute LogManager.Shutdown()?

Thank's! Sorry for my poor English.

This message and any files transmitted with it are confidential and are intended solely for the use of the individual or entity to whom they are addressed.  If you have received this email in error, please delete the email and any files transmitted with it entirely from your computer.
 

 

This message and any files transmitted with it are confidential and are intended solely for the use of the individual or entity to whom they are addressed.  If you have received this email in error, please delete the email and any files transmitted with it entirely from your computer.
 

Re: Problem CF + RollingFileAppender + Flush

Posted by Cícero Raupp Rolim <ir...@gmail.com>.
Hi Matt!

Your suggestion works fine!!! Thank you very much to help me to solve this
problem :D!

Att,

Cícero

On Fri, Feb 22, 2008 at 2:56 PM, Lee, Matthew <ml...@fhlbdm.com> wrote:

>  Let me clarify my response.  I had a similar challenge with the
> AdoNetAppender, which I fixed with the following configuration:
>
>   <appender name="AdoNetAppender" type="log4net.Appender.AdoNetAppender">
>     <bufferSize value="0" />
>     ....
>   </appender>
>
> This resulted in records being written out immediately.  I was hoping
> you could do something similar with your appender.  As far as a "flush"
> command, I'm not sure.  I'll leave that to more knowledgeable people on the
> list.
>
> Thanks,
>
> Matt
>
>  ------------------------------
> *From:* Cícero Raupp Rolim [mailto:ironworld@gmail.com]
> *Sent:* Friday, February 22, 2008 11:49 AM
> *To:* Log4NET User
> *Subject:* Re: Problem CF + RollingFileAppender + Flush
>
> Hi Matthew!
>
> I trying to read the content of last file of RollingAppender, but this
> file keep "0" size until next file be created. I think that if we call one
> method to flush data into file is one way to solve problem. Does log4net
> have one method to flush information to FileAppender without call
> LogManager.ShutDown()?
>
> Thanks!
>
> Cícero
>
> On Fri, Feb 22, 2008 at 2:38 PM, Lee, Matthew <ml...@fhlbdm.com> wrote:
>
> >  Does it help to set the buffer size to zero in the log4net
> > configuration?
> >
> > Thanks,
> >
> > Matt
> >
> >  ------------------------------
> > *From:* Cícero Raupp Rolim [mailto:ironworld@gmail.com]
> > *Sent:* Friday, February 22, 2008 11:36 AM
> > *To:* log4net-user@logging.apache.org
> > *Subject:* Problem CF + RollingFileAppender + Flush
> >
> >   Hi!
> >
> > We are developing an application for compact .NET framework 2.0. We need
> > log events and view and real time. We configured the app.config file
> > like presented below:
> >
> > <?xml version="1.0" encoding="utf-8" ?>
> > <configuration>
> >   <log4net>
> >     <appender name="RollingFileAppender" type="
> > log4net.Appender.RollingFileAppender">
> >       <file value="test.txt" />
> >       <appendToFile value="true" />
> >       <maxSizeRollBackups value="5" />
> >       <maximumFileSize value="100KB" />
> >       <rollingStyle value="Size" />
> >       <staticLogFileName value="true" />
> >       <layout type="log4net.Layout.PatternLayout">
> >         <conversionPattern value="%date [%thread] %-5level %logger
> > [%ndc] - %message%newline" />
> >       </layout>
> >     </appender>
> >     <root>
> >       <level value="ALL" />
> >       <appender-ref ref="RollingFileAppender" />
> >     </root>
> >   </log4net>
> > </configuration>
> >
> > After log some events, the file "test.txt" continues with 0 size. We
> > need execute method LogManager.Shutdown() to save file with these
> > events. Are there one way to log events in real time without execute
> > LogManager.Shutdown()?
> >
> > Thank's! Sorry for my poor English.
> >
> > This message and any files transmitted with it are confidential and are intended solely for the use of the individual or entity to whom they are addressed.  If you have received this email in error, please delete the email and any files transmitted with it entirely from your computer.
> >
> >
> >
> This message and any files transmitted with it are confidential and are intended solely for the use of the individual or entity to whom they are addressed.  If you have received this email in error, please delete the email and any files transmitted with it entirely from your computer.
>
>
>

RE: Problem CF + RollingFileAppender + Flush

Posted by "Lee, Matthew" <ml...@fhlbdm.com>.
Let me clarify my response.  I had a similar challenge with the
AdoNetAppender, which I fixed with the following configuration:
 
  <appender name="AdoNetAppender" type="log4net.Appender.AdoNetAppender">
    <bufferSize value="0" />
    ....
  </appender>
 
This resulted in records being written out immediately.  I was hoping you
could do something similar with your appender.  As far as a "flush" command,
I'm not sure.  I'll leave that to more knowledgeable people on the list.
 
Thanks,
 
Matt

________________________________

From: Cícero Raupp Rolim [mailto:ironworld@gmail.com] 
Sent: Friday, February 22, 2008 11:49 AM
To: Log4NET User
Subject: Re: Problem CF + RollingFileAppender + Flush


Hi Matthew!

I trying to read the content of last file of RollingAppender, but this file
keep "0" size until next file be created. I think that if we call one method
to flush data into file is one way to solve problem. Does log4net have one
method to flush information to FileAppender without call
LogManager.ShutDown()?

Thanks!

Cícero


On Fri, Feb 22, 2008 at 2:38 PM, Lee, Matthew <ml...@fhlbdm.com> wrote:


	Does it help to set the buffer size to zero in the log4net
configuration?
	 
	Thanks,
	 
	Matt

________________________________

	From: Cícero Raupp Rolim [mailto:ironworld@gmail.com] 
	Sent: Friday, February 22, 2008 11:36 AM
	To: log4net-user@logging.apache.org
	Subject: Problem CF + RollingFileAppender + Flush
	
	
	Hi!
	
	We are developing an application for compact .NET framework 2.0. We
need log events and view and real time. We configured the app.config file
like presented below:
	
	<?xml version="1.0" encoding="utf-8" ?>
	<configuration>
	  <log4net>
	    <appender name="RollingFileAppender"
type="log4net.Appender.RollingFileAppender">
	      <file value="test.txt" />
	      <appendToFile value="true" />
	      <maxSizeRollBackups value="5" />
	      <maximumFileSize value="100KB" />
	      <rollingStyle value="Size" />
	      <staticLogFileName value="true" />
	      <layout type="log4net.Layout.PatternLayout">
	        <conversionPattern value="%date [%thread] %-5level %logger
[%ndc] - %message%newline" />
	      </layout>
	    </appender>
	    <root>
	      <level value="ALL" />
	      <appender-ref ref="RollingFileAppender" />
	    </root>
	  </log4net>
	</configuration>
	
	After log some events, the file "test.txt" continues with 0 size. We
need execute method LogManager.Shutdown() to save file with these events. Are
there one way to log events in real time without execute
LogManager.Shutdown()?
	
	Thank's! Sorry for my poor English.
	
	This message and any files transmitted with it are confidential and
are intended solely for the use of the individual or entity to whom they are
addressed.  If you have received this email in error, please delete the email
and any files transmitted with it entirely from your computer.
	



This message and any files transmitted with it are confidential and are intended solely for the use of the individual or entity to whom they are addressed.  If you have received this email in error, please delete the email and any files transmitted with it entirely from your computer.


Re: Problem CF + RollingFileAppender + Flush

Posted by Cícero Raupp Rolim <ir...@gmail.com>.
Hi Matthew!

I trying to read the content of last file of RollingAppender, but this file
keep "0" size until next file be created. I think that if we call one method
to flush data into file is one way to solve problem. Does log4net have one
method to flush information to FileAppender without call LogManager.ShutDown
()?

Thanks!

Cícero

On Fri, Feb 22, 2008 at 2:38 PM, Lee, Matthew <ml...@fhlbdm.com> wrote:

>  Does it help to set the buffer size to zero in the log4net configuration?
>
> Thanks,
>
> Matt
>
>  ------------------------------
> *From:* Cícero Raupp Rolim [mailto:ironworld@gmail.com]
> *Sent:* Friday, February 22, 2008 11:36 AM
> *To:* log4net-user@logging.apache.org
> *Subject:* Problem CF + RollingFileAppender + Flush
>
> Hi!
>
> We are developing an application for compact .NET framework 2.0. We need
> log events and view and real time. We configured the app.config file like
> presented below:
>
> <?xml version="1.0" encoding="utf-8" ?>
> <configuration>
>   <log4net>
>     <appender name="RollingFileAppender" type="
> log4net.Appender.RollingFileAppender">
>       <file value="test.txt" />
>       <appendToFile value="true" />
>       <maxSizeRollBackups value="5" />
>       <maximumFileSize value="100KB" />
>       <rollingStyle value="Size" />
>       <staticLogFileName value="true" />
>       <layout type="log4net.Layout.PatternLayout">
>         <conversionPattern value="%date [%thread] %-5level %logger [%ndc]
> - %message%newline" />
>       </layout>
>     </appender>
>     <root>
>       <level value="ALL" />
>       <appender-ref ref="RollingFileAppender" />
>     </root>
>   </log4net>
> </configuration>
>
> After log some events, the file "test.txt" continues with 0 size. We need
> execute method LogManager.Shutdown() to save file with these events. Are
> there one way to log events in real time without execute
> LogManager.Shutdown()?
>
> Thank's! Sorry for my poor English.
>
> This message and any files transmitted with it are confidential and are intended solely for the use of the individual or entity to whom they are addressed.  If you have received this email in error, please delete the email and any files transmitted with it entirely from your computer.
>
>
>

RE: Problem CF + RollingFileAppender + Flush

Posted by "Lee, Matthew" <ml...@fhlbdm.com>.
Does it help to set the buffer size to zero in the log4net configuration?
 
Thanks,
 
Matt

________________________________

From: Cícero Raupp Rolim [mailto:ironworld@gmail.com] 
Sent: Friday, February 22, 2008 11:36 AM
To: log4net-user@logging.apache.org
Subject: Problem CF + RollingFileAppender + Flush


Hi!

We are developing an application for compact .NET framework 2.0. We need log
events and view and real time. We configured the app.config file like
presented below:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <log4net>
    <appender name="RollingFileAppender"
type="log4net.Appender.RollingFileAppender">
      <file value="test.txt" />
      <appendToFile value="true" />
      <maxSizeRollBackups value="5" />
      <maximumFileSize value="100KB" />
      <rollingStyle value="Size" />
      <staticLogFileName value="true" />
      <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="%date [%thread] %-5level %logger [%ndc] -
%message%newline" />
      </layout>
    </appender>
    <root>
      <level value="ALL" />
      <appender-ref ref="RollingFileAppender" />
    </root>
  </log4net>
</configuration>

After log some events, the file "test.txt" continues with 0 size. We need
execute method LogManager.Shutdown() to save file with these events. Are
there one way to log events in real time without execute
LogManager.Shutdown()?

Thank's! Sorry for my poor English.


This message and any files transmitted with it are confidential and are intended solely for the use of the individual or entity to whom they are addressed.  If you have received this email in error, please delete the email and any files transmitted with it entirely from your computer.