[syslog-ng] Continued struggle with getting shell env vars into log statements

jetjnkr at gmail.com jetjnkr at gmail.com
Mon Sep 29 21:48:21 CEST 2014


I'm trying to get an environment variable (As defined in the shell - take for example "HOSTNAME").  

echo $HOSTAME provides the expected string....  I then would like to append this to a set of messages based upon a specific destination.  I'm using syslog-ng 3.2.5. In this case the 'hostname' is just an example,  I know that the sending hostname is automatically prepended  - used here because it's commonly defined on systems.

I've included the following config lines from my syslog-ng.conf file.

destination d_web_call      { file("/var/log/web_call" template("<$PRI> $DATE $HOST $MSGHDR$MSG host=`HOSTNAME` \n") template_escape(no)); };
filter f_web_call                 { facility(local1) and ( match("^.*apache-call.*$" value("MSGHDR")) );};

log {
        destination (d_web_call);

Using the following test string:

/usr/bin/logger -t apache-call-tst -p local1.notice "This is a test message 25"

I get the following:

<141> Sep 26 17:21:18 lab.xxxx.com apache-call-tst: This is a test message25 host= 

I've received a few pointers from folks here (including going to 3.5 which can't be completed in the short term....).  If tried things with 'define' and using the '$' but not back-tick for the shell variable.  It is not clear when this value is set (if at all) within the config file.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.balabit.hu/pipermail/syslog-ng/attachments/20140929/4cf9793c/attachment.htm 

More information about the syslog-ng mailing list