Linux: get location of log files

I want my (python) script (located anywhere) to write a log file and put that log file in the appropriate location. On Linux: Debian can be / var / log.

I was wondering if this location of the log file could be fetched from the system? Is there an environment variable or something else?

+3


source to share


1 answer


The typical way to log on to Linux / UNIX systems is using the system logger. From your application (or daemon), you call a system function syslog

(see the man page).

This function will redirect your log to the system logger. From there the system logger will take care of writing these log messages to a file. Then you can customize the behavior of the logger to write some of your messages to a special file or ignore them.



For a straight forward answer to your question, it /var/log/

is defined by the FHS as where the log files should be written to.No need to rely on an environment variable.

+3


source







All Articles