logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Grzegorz Borkowski <grzegorzborkow...@o2.pl>
Subject Re: Appenders writing log file when not called apon
Date Fri, 28 Sep 2007 13:55:51 GMT

I'm facing the same problem - I have the file which should be created only if
there are any logs, otherwise the file shouldn't be created. Standard
FileAppender is not able to do so, as it seems.
Is there anybody out there who has written custom appender which creates
file lazily and could share the code with us?



Matthew Kemp-2 wrote:
> 
> I think it would be useful to implement your solution as a configurable
> parameter of an FileAppender. By default this delayFileCreation parameter
> would be false so log4j performs the same as now. However you could set
> the
> delayFileCreation parameter to true to cause the FileAppender to wait
> until
> it's ready to log to create/open a file. Just my 2 cents worth.
> 
> On 8/29/07, James A. N. Stauffer <stauffer.james@gmail.com> wrote:
>>
>> I would like the FileAppender to only create the file when about to
>> write the first log.
>>
>> On 8/29/07, Niraj Patel <nirajbpatel@googlemail.com> wrote:
>> > Cheers for the confirmation. I would rather fix this with via the
>> properties
>> > file, but if that aint possible then a code fix will have to do.
>> >
>> > Anyone lese think this feature is something that should be overideable
>> with
>> > a parameter or something?
>> >
>> > Niraj
>> >
>> >
>> >
>> > On 8/29/07, James A. N. Stauffer <stauffer.james@gmail.com> wrote:
>> > >
>> > > Log4j does creates files for every appender when initialized.  You
>> > > could write your own appender to change that.
>> > >
>> > > On 8/29/07, Niraj Patel <nirajbpatel@googlemail.com> wrote:
>> > > > I have a log4j.xml file which is used by dozens of classes
>> throughout
>> > > the
>> > > > day. One of these classes needs to log some data into a separate
>> file,
>> > > so I
>> > > > created the following config:
>> > > >
>> > > > <appender name="XXX" class="
>> org.apache.log4j.DailyRollingFileAppender">
>> > > >     
>> > > >     
>> > > >     
>> > > > </appender>
>> > > >
>> > > > <category name="a.b.c.XXXClass">
>> > > >     <appender-ref ref="XXX" />
>> > > > </category>
>> > > >
>> > > > Although the XXX.log file is written to disk (albeit empty) every
>> time
>> > > the
>> > > > log4j engine is initialised by the other classes.
>> > > >
>> > > > Am I correct in saying that the Log4J engine will parse all
>> appenders
>> > > and
>> > > > write any log files not on disk, to disk?
>> > > >
>> > > > Is there a way to stop this? I only want the log file to be written
>> onto
>> > > > disk when XXXClass logs data.
>> > > >
>> > > > Cheers in advance,
>> > > >
>> > > > Niraj
>> > > >
>> > >
>> > >
>> > > --
>> > > James A. N. Stauffer        http://www.geocities.com/stauffer_james/
>> > > Are you good? Take the test at http://www.livingwaters.com/good/
>> > >
>> > > ---------------------------------------------------------------------
>> > > To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
>> > > For additional commands, e-mail: log4j-user-help@logging.apache.org
>> > >
>> > >
>> >
>>
>>
>> --
>> James A. N. Stauffer        http://www.geocities.com/stauffer_james/
>> Are you good? Take the test at http://www.livingwaters.com/good/
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
>> For additional commands, e-mail: log4j-user-help@logging.apache.org
>>
>>
> 
> 

-- 
View this message in context: http://www.nabble.com/Appenders-writing-log-file-when-not-called-apon-tf4346717.html#a12941040
Sent from the Log4j - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Mime
View raw message