Logs Are Streams, Not Files

A program using stdout for logging can use syslog without needing to implement any syslog awareness into the program, by piping to the standard logger command available on all modern unixes:

$ mydaemon | logger

Perhaps we want to split the stream and log to a local file as well as syslog:

$ mydaemon | tee /var/log/mydaemon.log | logger

A program which uses stdout is equipped to log in a variety of ways without adding any weight to its codebase or configuration format.

Via http://news.ycombinator.com/item?id=2396695, which has an interesting comment about Google logging:

> Am I the only person that doesn't want logging to block or buffer?
If it's an error that you're logging the moment before you crash, then you probably want it to block.
At Google LOG(ERROR) blocks but LOG(INFO) doesn't, for this reason.

16 views and 0 responses