No, the code is perfectly valid. I guess the outer if evaluates to false.

Rainer

Sent from phone, thus brief.

David Lang via rsyslog <[email protected]> schrieb am Do., 17. Feb.
2022, 21:39:

> try:
>
> if ($hostname contains ‘srv1’) then {
>         if ($syslogfacility-text == 'local7') then {
>            /var/log/srv1_local7.log
>         } else {
>            if ($msg contains ‘PROXY’) then {
>              /var/log/srv1_proxy.log
>           } else {
>            /var/log/srv1_main.log
>           }
>           stop
>          }
> }
>
> David Lang
>
> On Thu, 17 Feb 2022, Antonio Leding via rsyslog wrote:
>
> > Date: Thu, 17 Feb 2022 20:35:48 +0000
> > From: Antonio Leding via rsyslog <[email protected]>
> > To: [email protected]
> > Cc: Antonio Leding <[email protected]>
> > Subject: [rsyslog] Nested if/else-if/else statements
> >
> > Hello rsyslog community,
> >
> > Are nested if/else-if/else statements supported?  For example, I tried
> > the following but this fails to grab any log messages:
> >
> > if ($hostname contains ‘srv1’) then {
> >       if ($syslogfacility-text == 'local7') then {
> >         /var/log/srv1_local7.log
> >       } else if ($msg contains ‘PROXY’) then {
> >         /var/log/srv1_proxy.log
> >       } else {
> >         /var/log/srv1_main.log
> >       }
> >       & stop
> > }
> >
> > Also, if I remove the “& stop” at the end, only the last statement
> > for ‘srv1_main.log’ grabs log messages.
> >
> > Thanks in advance.
> > _______________________________________________
> > rsyslog mailing list
> > https://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.
> _______________________________________________
> rsyslog mailing list
> https://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.
_______________________________________________
rsyslog mailing list
https://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