Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How should I log from a non-root Debian Linux daemon?

I'm writing a new daemon, which will be hosted on Debian Linux.

I've found that /var/log has root only write permissions, so my daemon cannot write log files there.

However, if it writes there, it appears it will gain automatic log rotation, and also work as a user might expect.

What is the recommended way for a daemon to write log entries that appear in /var/log, without having to be run as root?

The daemon is a webserver, so the log traffic will be similar to Apache.

like image 925
John McAleely Avatar asked Jan 27 '09 15:01

John McAleely


People also ask

Where should I put logs in Linux?

Linux systems typically save their log files under /var/log directory. This works fine, but check if the application saves under a specific directory under /var/log . If it does, great. If not, you may want to create a dedicated directory for the app under /var/log .

How do I enable system logs in Linux?

To enable server-to-server events for logging to the system log, you can issue the DEFINE EVENTSERVER, BEGIN EVENTLOGGING, and ENABLE EVENTS commands. For example, to set up logging between server A and server B, issue the following commands: Server A.

Where is the system log in Linux?

Linux System Logs Linux has a special directory for storing logs called /var/log . This directory contains logs from the OS itself, services, and various applications running on the system.

What are OS logs in Linux?

Linux logs provide a timeline of events for the Linux operating system, applications and system and are a valuable troubleshooting tool when you encounter issues. When issues arise, analyzing log files is the first thing an administrator needs to do.


1 Answers

You should create a subdirectory like /var/log/mydaemon having the daemon's user ownership

like image 69
WiseTechi Avatar answered Sep 28 '22 08:09

WiseTechi