On Mon, 10 Feb 2014, Micah Yoder wrote:

So is something like this possible? I am writing a template with a few
parts - a base directory name, the hostname of the originating server,
and then the log file name.  After defining the template, some
conditions for the different files.  I just want a different file based
on different conditions, without redefining the template.  So, something
like:

template(name="tpltest" type="list") {
   constant(value="/var/log/")
   property(name="hostname")
   constant(value="/")
   property(name="$.filename")
}

   if $programname == "micah" and $syslogfacility-text == 'local1' then {
       set $.filename = "loggerstuff"
       action(type="omfile" Template="tpltest" DirOwner="root"
DirGroup="root" FileOwner="root" FileGroup="root" DirCreateMode="0755"
FileCreateMode="0644")
   }

   if $programname == "puppet-agent" and $syslogfacility-text ==
'local1' then {
       set $.filename = "puppet"
       action(type="omfile" Template="tpltest" DirOwner="root"
DirGroup="root" FileOwner="root" FileGroup="root" DirCreateMode="0755"
FileCreateMode="0644")
   }


It doesn't seem to be parsing in 7.4.4 which I have installed, but I
might be doing something wrong.  If it isn't possible in this version,
is it in 7.5.x or 8.1.x?

This is exactly the type of thing that local variables were designed for. But just to check, try doing $! instead of $. the variable will show up as part of a JSON output of $! if you do this, but it will let you test if this is the problem

David Lang
_______________________________________________
rsyslog mailing list
http://lists.adiscon.net/mailman/listinfo/rsyslog
http://www.rsyslog.com/professional-services/
What's up with rsyslog? Follow https://twitter.com/rgerhards
NOTE WELL: This is a PUBLIC mailing list, posts are ARCHIVED by a myriad of 
sites beyond our control. PLEASE UNSUBSCRIBE and DO NOT POST if you DON'T LIKE 
THAT.

Reply via email to