syslog-ng on Ubuntu


apt-get install syslog-ng

The configuration file is at


Some basic syntax

To define the log to be printed out on all terminals. This normally available in the default configuration file.

destination <identifier> { pipe("/dev/xconsole"); };

To define a file where log should be directed to.

destination <identifier> { file("<file name in full path>"); };

To format the log, you can use template in your destination.

destination <identifier> { file("<file name in full path>" template("$ISODATE:$MESSAGE")); };

If you would like to fully format the logline, you can use $MSGONLY. However, please remember to put a newline character at the end of the template.

Filters can be set based on facility, priority, program name, keyword matching and etc. You can refer to this :

filter <identifier> { facility(<facility>); };

You can also put logical operator in the filter.

filter <identifer> { program("test") and level(err); };

After you have set the destination and filter, you can start to configure the logging redirection.

Example I used in my system.

How do I test it? you can simply use logger command.

If you do not specify the priority in the logger command, it will assumed as notice level.

Another finding from my experiment. In the configuration file, there's an option to allow system to create the destination file. See in the options {}; section. It will create only for the first time usage. If you "accidentally" removed the created log file, it will not recreate it until the syslog-ng service is restarted again.

Have fun!


Popular posts from this blog

Network Manager

CCSP Domain 2 : Cloud Data Security - Part 2

How to enable LAN network to access to web server hosted in Oracle VirtualBox