| From my reading of his Web pages, djb's general attitude seems to be this: qmail is an ncredibly high-performance mail server. All mail server activity should be logged, but when he tried to send this output to standard syslog on various Unix flavors, syslog dropped lines under high load. Therefore syslog is completely broken and should be discarded, and since he suffers from an extreme case of Not-Invented-Here syndrome, his replacement is multilog. |
|
The
output of qmail (or of tcpserver, his inbound SMTP or
other socket listener, or of any program) is piped into standard input of
multilog. multilog takes a number of arguments on the
command line which tell it where to put the logs, whether to timestamp each
line, how big one log file should get (bytes, not length of time) before
rotating and starting a new file, etc. The current log is named "current",
and when it fills up, it gets renamed to "bignumerictimestamp.s",
where all the timestamps are in an extremely precise and long-ranged format
called TAI64 (precise down to the picosecond or something, range out to
the age of the universe). When you're reading a log back out, he has a utility
called tai64nlocal through which you can pipe the lines, and it
will manufacture a date/time in local format and timezone. If multilog
terminates cleanly, it renames the "current" file to another name,
and when it starts up again, it names it back to "current", so
you know nothing funny happened. If the machine crashes or multilog
is otherwise killed harshly, then when it starts up again "current"
already exists, and it renames that file to a ".u" file to flag
it as possibly incomplete or corrupted, then begins a new "current".
After a while, then, a log directory will look like...
(Note that the finished files are ".s" and have the execute bit set, while the unexpectedly-cut-off ones are ".u" and do not have x set.) A file will contain lines like...
...which when piped through tai64nlocal in a shell set for the Eastern U.S. time zone, produces...
Since (in his opinion) there's no standardized and good-quality way to maintain services that are easily started, signaled, stopped, and restarted automatically when they crash, he also wrote the "supervise" program to do these jobs. If you make a "/service/qmail" directory for supervising qmail itself, plus a "/service/qmail/log" subdirectory for the logging service that's associated with it, they will be both started nicely together and the output of one will be automatically piped into the other, and if either one crashes it will be restarted and the pipes reattached without text loss, so you won't have a situation where the service continues but the logs are lost forever. So djb's whole worldview fits together nicely, if you buy into it. Main differences from standard logging:
djb also has an incredibly terse, blunt, unsympathetic, and one even might say hard-headed style of documentation for man pages and INSTALL documents, which you'll see if you poke around his site a little. His apparent rationale is this: Here I have presented "just the facts, ma'am", precisely those facts and steps which should be necessary and sufficient for you to accomplish the task you're attempting with my software. If you can't follow directions precisely, then you will fail and you deserve to fail; just ask someone else more competent to help you. If there aren't any usage examples for a program, that's because you should be able to completely digest the man page of a program you've never seen before, juggle all the command-line option combinations in your head, and come up with the exact configuration that will do what you want, and if you can't, then again you probably need to consult an oracle or a more experienced admin." With that said, then, my simple logging for my qmail server sends its output to "multilog t s1000000 n2000 /var/log/qmail", which means to collect logs in /var/log/qmail/*, timestamp each line, keep up to 1MB in each file, and keep up to 2000 files before throwing away the oldest. (Therefore this will retain about the most recent 2GB of logs.) If you use the above "supervise" directory structure, the upper-level service "run" script starts the program sending output to normal standard out (probably with the clever "exec 2>&1" shell trick to collapse standard error into standard out as well), and then the "run" script for the log subdirectory is simply something like...
This uses his setuidgid program to demote the logging process into running non-root, so the /var/log/qmail directory must be writable by the ordinary user qmail. Also, I guess djb knows that
some people are accustomed to syslog and won't instantly switch
from it, so he includes a utility with qmail called "splogger"
that simply takes lines from standard-in and sends them to syslog.
|
|
| [Optional] | |
| [Optional] |