Thirupathi Thangavel Thirupathi Thangavel - 15 days ago 7
Linux Question

Setting permisison of log file in rsyslog configuration

There is an option in rsyslog configuration to set the permission & ownership of the log file created.

$fileOwner sv
if $programname contains 'my_process' then /var/log/my_process.log


If the log file (
/var/log/my_process.log
) is not present, the file will be created with owner as "sv" user. Manual

But this will change the setting for all the forthcoming files as well.

Is there a way to the set the permission of only a particular log file?

Answer

I've found a way that works. After the configuration, reset the variable back to its default value.

$fileOwner sv
if $programname contains 'my_process' then /var/log/my_process.log
$fileOwner root