While debugging the syslog-ng issue I mentioned previously, I needed to be able to observe the syslog-ng pattern matches as they occurred. The syslog-ng daemon has a couple of useful options to assist with this. The first is the “-e” option, which causes the daemon to log to stdout. The second is the “-F” option, which stops the daemon from forking. When you combine these option with the “-d” (debug) and “-v” (verbose) options, syslog-ng will print each log message it receives along with the rule processing logic that is applied to that rule:
/opt/syslog-ng/sbin/syslog-ng -e -F -d -v > /tmp/syslog-ng.out 2>&1
Incoming log entry; line='<85>sshd2: Public key /root/.ssh/id_rsa_1024.pub used.x0a' Filter rule evaluation begins; filter_rule='f_web_hosts' Filter node evaluation result; filter_result='match', filter_type='level' Filter node evaluation result; filter_result='not-match' Filter node evaluation result; filter_result='not-match' Filter node evaluation result; filter_result='not-match', filter_type='OR' Filter node evaluation result; filter_result='not-match', filter_type='AND' Filter rule evaluation result; filter_result='not-match', filter_rule='f_web_hosts' Filter rule evaluation begins; filter_rule='f_app_hosts'
When a syslog message matches a given rule, you will see the filter_result string change from not-match to match:
Filter rule evaluation result; filter_result='match', filter_rule='f_db_hosts'
Syslog-ng is pretty sweet, and you can check out my centralized logging presentation if you are interested in learning more about how this awesome piece of software works!