Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Contact Us
Online Help
Domain Status
Man Pages

Virtual Servers

Topology Map

Server Agreement
Year 2038

USA Flag



Man Pages

Manual Reference Pages  -  LOG::DISPATCH::FILE::ROLLING (3)

.ds Aq ’


Log::Dispatch::File::Rolling - Object for logging to date/time/pid stamped files



  use Log::Dispatch::File::Rolling;

  my $file = Log::Dispatch::File::Rolling->new(
                             name      => file1,
                             min_level => info,
                             filename  => Somefile%d{yyyyMMdd}.log,
                             mode      => append );

  $file->log( level => emerg,
              message => "Ive fallen and I cant get up\n" );


This module provides an object for logging to files under the Log::Dispatch::* system.


This module subclasses Log::Dispatch::File for logging to date/time stamped files. See Log::Dispatch::File for instructions on usage. This module differs only on the following three points:
fork()-safe This module will close and re-open the logfile after a fork.
multitasking-safe This module uses flock() to lock the file while writing to it.
stamped filenames This module supports a special tag in the filename that will expand to the current date/time/pid.

It is the same tag Log::Log4perl::Layout::PatternLayout uses, see Log::Log4perl::Layout::PatternLayout, chapter Fine-tune the date. In short: Include a %d{...} in the filename where ... is a format string according to the SimpleDateFormat in the Java World ( See also Log::Log4perl::DateFormat for information about further restrictions.

In addition to the format provided by Log::Log4perl::DateFormat this module also supports ’$’ for inserting the PID. Repeat the character to define how many character wide the field should be. This should not be needed regularly as this module also supports logfile sharing between processes, but if you’ve got a high load on your logfile or a system that doesn’t support flock()...


new() See Log::Dispatch::File and chapter DESCRIPTION above.
log_message() See Log::Dispatch::File and chapter DESCRIPTION above.


0.99 Original version; created by h2xs 1.22 with options


1.00 Initial coding
1.01 Someone once said Never feed them after midnight!---Ok, let’s append: Never submit any code after midnight...

Now it is working, I also included 4 tests.

1.02 No code change, just updated Makefile.PL to include correct author information and prerequisites.
1.03 Changed the syntax of the ’$’ format character because I noticed some problems while making Log::Dispatch::File::Alerts. You need to change your configuration!
1.04 Got a bug report where the file handle got closed in mid-execution somehow. Added a additional check to re-open it instead of writing to a closed handle.
1.05 Updated packaging for newer standards. No changes to the coding.
1.06 Fixed a subtle bug that prevented us from locking the logfile after a fork if no PID was used in the filename.

Also disabled forced double opening of the logfile at startup. It was in place because I didn’t trust Log::Dispatch::File to really open the file at the right moment.

Thanks to Peter Lobsinger for the patch. Please always wrap non-standard Test::* modules in eval and make your testfile clean up after itself... ;)

1.07 Fixed bug #89001. Seems Log::Dispatch::File changed its initialization procedure---and we are inheriting from it.
1.08 Fixed dependency on Log::Dispatch::File. The change in 1.07 only works with 2.37 or later. For older versions of Log::Dispatch::File use 1.06.
1.09 Dependency change of 1.08 was missing from the Makefile.PL. Oops.


Log::Dispatch::File, Log::Log4perl::Layout::PatternLayout,, Log::Log4perl::DateFormat, ’perldoc -f flock’, ’perldoc -f fork’.


M. Jacob, <>


Copyright (C) 2003, 2004, 2007, 2010, 2013 M. Jacob <>

Based on:

  Log::Dispatch::File::Stamped by Eric Cholet <>
  Log::Dispatch::FileRotate by Mark Pfeiffer, <>

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

Search for    or go to Top of page |  Section 3 |  Main Index

perl v5.20.3 LOG::DISPATCH::FILE::ROLLING (3) 2014-01-27

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.