Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Log4perl log rotation in threadpool environment

by space_monk (Chaplain)
on Nov 16, 2012 at 09:45 UTC ( #1004162=note: print w/ replies, xml ) Need Help??


in reply to Log4perl log rotation in threadpool environment

Maybe you can:

  1. copy the existing log file to a new name
    e.g. copy log_file to log_file.2012-11-16
  2. truncate the log file
  3. Optionally zip the archive file

That way the file handle for the log file doesn't change.

A Monk aims to give answers to those who have none, and to learn from those who know more.


Comment on Re: Log4perl log rotation in threadpool environment
Re^2: Log4perl log rotation in threadpool environment
by rmahin (Beadle) on Nov 16, 2012 at 18:29 UTC
    Thanks! That was my original idea actually but wasnt aware I could erase (truncate was apparently the word I should have search on) the contents of the file with file handle open. Changed my obnoxious swapping code to
    copy($currFile, $logDir. $self->{old_logs_name}. '.1') or die +"Could not copy the log file because $!"; my $fh = $self->{fh}; truncate($fh, 0) or die "Could not truncate the log file becau +se $!"; seek($fh, 0, 0) or die "Could not set the position in the log +file because $!";
    Thanks again!
      Another satisfied customer :-)
      A Monk aims to give answers to those who have none, and to learn from those who know more.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1004162]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (5)
As of 2015-07-03 23:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (57 votes), past polls