File: README

package info (click to toggle)
flog 1.8%2Borig-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, buster
  • size: 168 kB
  • sloc: ansic: 1,278; makefile: 48; sh: 12
file content (84 lines) | stat: -rw-r--r-- 2,874 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84

WHAT IS IT?
===========

flog (file logger) is a program that reads input from STDIN
and writes to a file. if a SIGHUP is received, the file will be
reopened, allowing for log rotation [see logrotate(8) on RH.]
The log file will only be reopened if flog detects that
rotation has occurred (ie, old file gone or inode changed).
flog is very small (less than 500 bytes memory footprint.)


USAGE
=====

Typically flog is used to log STDERR output from a daemon.
It's also very useful with Apache. This way you never have
to HUP apache itself:
	ErrorLog	"|/bin/flog /httpd/logs/error_log"

Typical example:
	(mydaemon >stdout.file) |& flog [-t] stderr.file

this will redirect daemon's STDOUT to a file called "stdout.file"
and STDERR (thru flog) to "stderr.file". (example uses zsh: the
best shell! like bash but better)

The -t option causes a timestamp to be prepended to each line.

The -T <format> option causes a timestamp to be prepended to each line
with a user specified time format. See strftime(3) for how to specify
the format.

The -z option (pre-1.8 default behavior) causes the log file to be
truncated to free up disk space in case the device gets full. In v1.8
the default is now to buffer additional data in ram until there is
disk space available again.

Logging output of a multi-instance program
==========================================

If the program that produces output has more than one instance logging should
be done via a fifo, not a pipe, otherwise records will be lost during a reload.
For example in the case of Apache:
    CustomLog /some/path/fifo-name

where fifo-name is created with mkfifo. Then start flog with
    flog -F /some/path/fifo-name output-file

BEFORE launching the daemon. With the -F option flog will run forever, even if
the daemon terminates. If you want to stop it use kill pid-of-flog.

FEATURES
========

if flog fills up a device (write returns ENOSPC), the log file
will be truncated back to 0 and restarted. (this is an emergency
avoidance feature only! always use logrotate to recycle logs)

send as many HUPs as you want to flog, when a HUP is caught,
the LOG will only be reopened if flog detects a logrotation.
(ie, inode changed, or file disappeard)

CHANGE LOG
==========
version 1.4 2005-01-17
	Added large-file support (-D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE=1) O_LARGEFILE
version 1.5 2005-02-04
	Re-arm signal handler (needed for solaris. thanks Claude)
version 1.6 2005-06-02
	Now compiles on OpenBSD
version 1.7 2005-09-01
	Added -l option to limit file length (patch by dsong@teramail.com)
2007-06-20
	Added -p to write pid file  (patch by manon@manon.de)
version 1.8 2009-02-04
	Added -z option, but the default is now to buffer, not to truncate log if disk gets full.

AUTHOR
======

Copyright (c) 2001-2009 Fredrik Sjoholm <fredrik@sjoholm.com>
License: GPL - The GNU General Public License