Linux syslog utility

This is a small C program to write a message to the Linux system log with the specified priority.

The example program has been tested on Red Hat x86 versions 6.1 through 7.3, Ubuntu 7.04 and 7.10, OSX 10.4.

Invocation

The program can be invoked from a script as follows:

slog2 alert "This is an alert message"
slog2 crit "This is a critical message"
slog2 debug "This is a debug message"
slog2 emerg "This is an emergency message"
slog2 crit "This is a critical message"
slog2 error "This is an error message"
slog2 info "This is an info message"
slog2 notice "This is a notice message"
slog2 warning "This is a warning message"

You can download this script (slog2-test) here.

Parameters

  1. Message priority.  See "Invocation" above.
  2. The message string to be written.

Source Code

The source code is here: slog2.c.

Compilation

Use this command:

	cc slog2.c -o slog2

Ignore the warning messages.

Enjoy!

Updated 2007-12-16