I want to write a logfile of activities of my program. Does it always go to /var/log/
or /var/log/appname/
if multiple files are written? Is there a common environment variable like $LOGDIR
? What would be the POSIX way to do that? Also, what is the expected log filename on *nix? Something like {name}.{date}.{pid}.log
?
Does it always go to /var/log/ or /var/log/appname/ if multiple files are written?
Absolutely not. Logs may not even be stored on the local system (they may be shipped off to a remote collector using any of a variety of technologies).
Is there a common environment variable like $LOGDIR? What would be the POSIX way to do that?
Again, no such luck. For applications that log to syslog
, the configuration may be in /etc/syslog.conf
, or /etc/rsyslog.conf
, or even somewhere else if a different syslog server is in use. For applications that don't log to syslog, it's a per-application configuration.
Also, what is the expected log filename on *nix? Something like {name}.{date}.{pid}.log?
There is no expected log filename. It varies from application to application.