Hack Saw
Home · News · Download · netsyslog


netsyslog is a Python module that enables you to construct syslog messages and send them (via UDP) to a remote syslog server. Unlike other syslog modules it allows you to set the metadata (e.g. time, host name, program name, etc.) yourself, giving you full control over the contents of the UDP packets that it creates.

netsyslog was initially developed for the Hack Saw project, where it is used to read log messages from a file and inject them into a network of syslog servers, whilst maintaining the times and hostnames recorded in the original messages.

The module is also suitable for use in the more common circumstance where you just want to create and send a log message that is marked with your process name and ID, hostname, etc.

The format of the UDP packets sent by netsyslog adheres closely to that defined in RFC 3164.


Download the package from SourceForge:

Untar the package and install it, as follows:

	$ tar zxf netsyslog-0.1.0.tar.gz
	$ cd netsyslog-0.1.0
	$ su -
	# python setup.py install

You should then be able to try sending a log message, as follows:

        $ python
	Python 2.4.1 (#2, Mar 30 2005, 21:51:10)
	[GCC 3.3.5 (Debian 1:3.3.5-8ubuntu2)] on linux2
	Type "help", "copyright", "credits" or "license" for more information.
	>>> import netsyslog
	>>> import syslog
	>>> logger = netsyslog.Logger()
	>>> logger.add_host("somehost.mydomain.com")
	>>> logger.add_host("otherhost.mydomain.com")
	>>> logger.log(syslog.LOG_USER, syslog.LOG_NOTICE, "Hey, it works!", pid=True)

If you don't see your messages appearing on your syslog server, check the syslog configuration file and ensure that your server is configured to listen for incoming connections.


The API is fully documented. You may also benefit from reading parts of the RFC that defines the format of a syslog packet.