[syslog-ng] [patch] new feature for file destination: persistent symlinks

a.biardi at tiscali.it a.biardi at tiscali.it
Sat Dec 4 14:29:35 UTC 2021

Hi all,

I'm new here. I love syslog-ng: it's well written and documented and
each time I need some new feature, I dig up the documentation and I
find it's already implemented!

Like many others, I use macros in file destinations (say,
"/var/log/cron.${YEAR}${MONTH}"), but I also want to maintain a
persistent symlink to the current logfile (that would be
something like "/var/log/cron") in order to have "easier" access if I'm
grepping for something manually.

I couldn't find this feature in syslog-ng, so I wrote the code myself;
in the configuration file, it looks like this:

destination d_file_cron {
  file("/var/log/cron.${YEAR}${MONTH}" symlink_as("/var/log/cron"));

It works for me on my Slackware boxes. I'm sharing the patch I put
together, hoping that it may be useful to others and perhaps even
considered for inclusion in mainstream.

From a functional perspective, the "symlink_as" file inherits both
"create-dirs" and file ownership from its file destination (permissions
are not applicable to symlinks, at least on linux).

Patch applies cleanly to latest production release (3.33). I tried to
keep the original coding style for easier review (admittedly, the code
could have gone into the function that opens the file destination, but
I didn't want to change too much).

Thanks for the good work and happy logging!

-------------- next part --------------
A non-text attachment was scrubbed...
Name: filedest-symlink-as.diff
Type: text/x-patch
Size: 8526 bytes
Desc: not available
URL: <http://lists.balabit.hu/pipermail/syslog-ng/attachments/20211204/6e1880b7/attachment.bin>

More information about the syslog-ng mailing list