Re: Weird behavior in logrotate
From: Kasper Dupont (remove.invalid_at_nospam.lir.dk.invalid)
Date: 07/31/04
- Previous message: Larry I Smith: "Re: Weird behavior in logrotate"
- In reply to: Larry I Smith: "Re: Weird behavior in logrotate"
- Next in thread: Larry I Smith: "Re: Weird behavior in logrotate"
- Reply: Larry I Smith: "Re: Weird behavior in logrotate"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sat, 31 Jul 2004 06:43:19 +0200
Larry I Smith wrote:
>
> The way we had to solve this problem in our older systems
> (in a manner that is OS portable) is to modify the Java program
> to NOT keep the file open. Every time the Java prog wants to write
> to the log file it calls a Java method that opens the file in append
> mode, performs the write, then closes the file.
If you can actually make java open the file in append
mode, then it shouldn't be necesarry to repoen the
file every time you access it. The described symptoms
is what happens if the file is not opened in append
mode.
Actually if you don't use append mode, but reopen
the file every time, you will have race conditions.
Imagine if the truncate happens between the java
program seeking to the end of the file and calling
write.
Even when using append mode you will have a race
condition that could cause loss of log messages.
A write could happen after the log had been copied
but before it was truncated.
-- Kasper Dupont -- der bruger for meget tid paa usenet. I'd rather be a hammer than a nail.
- Previous message: Larry I Smith: "Re: Weird behavior in logrotate"
- In reply to: Larry I Smith: "Re: Weird behavior in logrotate"
- Next in thread: Larry I Smith: "Re: Weird behavior in logrotate"
- Reply: Larry I Smith: "Re: Weird behavior in logrotate"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|