This commit is contained in:
Darren 'Tadgy' Austin 2018-04-21 22:14:22 +01:00
commit 6e4bf7d7d7

View file

@ -1,11 +1,11 @@
# Lumberjack # Lumberjack
In its simplest form, lumberjack is a pipe logger for Apache HTTPd (and other daemons). In its simplest form, lumberjack is a pipe logger for Apache HTTPd and other daemons.
Lumberjack can be used as the logger for piped log files using the HTTPd `CustomLog` directive - processing each log line and writing it out to the correct - per `VirtualHost` - log file. It may also be used by other daemons capable of writing log files to a pipe, or via a FIFO. Lumberjack can be used as the logger for piped log files using the HTTPd `CustomLog` directive - processing each log line and writing it out to the correct - per `VirtualHost` - log file. It may also be used by other daemons capable of writing log files to a pipe, or via a FIFO.
In contrast to having one logger process per `VirtualHost` (or a hard coded log file for each `VirtualHost`, as is the norm), lumberjack can be set as the pipe logger in the global section of the *httpd.conf* file, and - with an appropriate `LogFormat` specifier - will split off each log line for a different `VirtualHost` and write it to a per `VirtualHost` log file based upon a user defined template. In contrast to having one logger process per `VirtualHost` (or a hard coded log file for each `VirtualHost`, as is the norm), lumberjack can be set as the pipe logger in the global section of the *httpd.conf* file, and - with an appropriate `LogFormat` specifier - will split off each log line for a different `VirtualHost` and write it to a per `VirtualHost` log file based upon a user defined template.
Lumberjack may also be used in 'raw' mode in combination with the HTTPd `ErrorLog` directive to log errors, either on a per server or per `VirtualHost` basis to a log file based upon a user supplied template. Lumberjack may also be used in 'raw' mode in combination with the HTTPd `ErrorLog` directive to log errors, either on a per server or per `VirtualHost` basis to a log file based upon a user supplied template. 'raw' mode also allows other daemons to log via lumberjack, either as a pipe logger or via a FIFO.
### Additional features ### Additional features
* Automatic log file compression (using a user specifiable compressor) after log files are rotated. * Automatic log file compression (using a user specifiable compressor) after log files are rotated.
@ -61,15 +61,31 @@ Create a new `LogFormat` entry (in this case named "VHostCombined") in the globa
LogFormat "%v %h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" VHostCombined LogFormat "%v %h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" VHostCombined
``` ```
Then locate the `CustomLog` directive in the *httpd.conf*. Or you may need to add this if there is none already present.
### As a per `VirtualHost` `CustomLog` pipe logger The format for the `CustomLog` directive for use with lumberjack is:
```
CustomLog "|/path/to/lumberjack -l access.log -z /path/to/basedir {}/logs/access-%Y-%m.log" VHostCombined
```
Here, the `-l` and `-z` flags specify extra options to lumberjack - they can be omitted if you do not require them. The template (final argument) is just an example based upon my personal layout for the directories that was given as an example earlier.
### As an Apache HTTPd `ErrorLog` pipe logger ### As an Apache HTTPd `ErrorLog` pipe logger
Lumberjack can also be used to handle error logs generated by Apache HTTPd in almost the same way as the `CustomLog` example above. The only difference is the addition of the `-r` option, to tell Lumberjack it should be working in 'raw' mode.
In 'raw' mode, no procesing of the log line is performed - the `VirtualHost` identifier is not extracted to be used as part of the log file name, and the log line is written verbatim.
In 'raw' mode, the template (and link name if specified) cannot include the special `{}` string, which is usually replaced with the `VirtualHost` identifier when in 'normal' mode - Lumberjack will not start if either of those options include a `{}` sequence.
```
ErrorLog "|/path/to/lumberjack -r /path/to/basedir/<virtualhost name>/logs error-%Y-%m.log"
```
### As a generic 'raw' pipe logger (for use with other daemons) ### As a generic 'raw' pipe logger (for use with other daemons)
### With a FIFO (for use with other daemons) ### With a FIFO
Using lumberjack with daemons that do not support pipe logging is as simple as setting up a FIFO for them to write their logs to, and telling lumberjack where to find it.
To do this, use the `-i` flag to tell lumberjack where to locate the FIFO for the daemon from which you want to log. All other command line options are the same as detailed in the other examples..