One of the most frequent syslog-ng feature requests is now resolved. Welcome the --check-startup option, allowing you to check the syntax and also spot spelling mistakes!

Before you begin

To use the --check-startup option, you need version 4.5.0 or later of syslog-ng. If your favorite operating system does not have it yet, you can check https://syslog-ng.org/3rd-party-binaries/ if there are ready-to-use third-party syslog-ng packages for your OS.

Testing

Once you have syslog-ng 4.5.0 or later up and running, testing the new feature is easy. Just create a typo in your configuration and check it. If you use the good old -s option, it will not spot the typo, as it only checks for syntax errors:

[root@fedora ~]# syslog-ng -s
[root@fedora ~]#

However, if you run syslog-ng using the new --check-startup option, you will immediately see the difference:

[root@fedora ~]# syslog-ng --check-startup
Error resolving reference; content='destination', name='d_fajl', location='/etc/syslog-ng/conf.d/otel.conf:15:21'
[root@fedora ~]#

In this example, --check-startup found one of my typical problems: mixing the English and Hungarian spelling of the same word…

False positives

When you use the --check-startup option, syslog-ng does a full initialization to catch any errors. This, however, has a side effect: if the configuration includes a network source which is in use by a running syslog-ng instance, then syslog-ng will throw an error message, even if the configuration itself does not have any problems:

[root@fedora ~]# syslog-ng --check-startup
Error binding socket; addr='AF_INET(0.0.0.0:514)', error='Address already in use (98)'
Error initializing message pipeline; plugin_name='tcp', location='/etc/syslog-ng/conf.d/otel.conf:2:3'
[root@fedora ~]#

In practice, this probably means that you cannot use the --check-startup option in a script. However, even with this limitation, this new option allows you to spot spelling mistakes before adding new configurations to your live environment, minimizing downtime.

What is next?

With a bit of extra work, you might be able to create a script which detects false positives, like network ports already in use.

-

If you have questions or comments related to syslog-ng, do not hesitate to contact us. You can reach us by email or even chat with us. For a list of possibilities, check our GitHub page under the “Community” section at https://github.com/syslog-ng/syslog-ng. On Twitter, I am available as @PCzanik, on Mastodon as @Pczanik@fosstodon.org.

Related Content