WARNING: This server is unstable and will be retired in the next days. If you want to keep this forum available, please request immediately a migration on the Nabble Support forum. Forums that don't receive any migration request will be deleted forever.

 « Return to Thread: How to prevent creating log file ???

Re: How to prevent creating log file ???

by Stefan Bodewig :: Rate this Message:

| View in Thread

On 2011-10-13, Radovan Raszka wrote:

>> -----Původní zpráva-----
>> Od: Stefan Bodewig [mailto:bodewig@...]
>> Odesláno: 13. října 2011 6:39
>> Komu: Log4NET User
>> Předmět: Re: How to prevent creating log file ???

>> On 2011-10-12, Sigourney_Weaver wrote:

>>> Thank you, but it didnt work :(

>>> For the second appender I specified: <lockingModel
>>> type="log4net.Appender.FileAppender+MinimalLock" />

>>> but it still creates the empty log file (and I dont log any FATAL errors).

>> Yes, my fault.  I overlooked that FileAppender.OpenFile acquires the
>> lock before calling SetQWForFiles (not sure it needs a lock there, will
>> investigate) and once again in order to write the header.

I don't think there is much we can do without breaking the semantics of
the existing protected API of FileAppender - i.e. without breaking
backwards compatibility.

>> So no, there is no way with the current FileAppender to avoid the empty
>> files.

> Well, it is :) but some programming is needed
> See this post http://mail-archives.apache.org/mod_mbox/logging-log4net-user/200708.mbox/%3C2DE096D91923074A82B1E17ADC480EC80135926F@...%3E

This works for turning logging on/off but not for the case where you may
or may not have messages and don't want any file if no messages have
been logged.

Stefan

 « Return to Thread: How to prevent creating log file ???