Sending UDP packets with `logger` command

I have couple different solutions for running custom syslog server (based on https://gist.github.com/marcelom/4218010).

The problem I am facing is that the following command does not send UDP packets to the server:

logger -n 127.0.0.1 -P 514 "Test message"

Do I properly send a test message?

Any ideas on what I am doing wrong? The scripts apparently should work, but I am unable to confirm they work during tests.

EDIT: I confirmed that syslog receiver is indeed receiving messages sent with UDP protocol. Thus I also clarified the question removing this piece.


An other solution with netcat :

echo -n "test message" | nc -4u -w1 <host> <udp port>


I lost some sanity trying to figure out why I couldn't log across different machines to test our remote logging yesterday

It turns out the util-linux/bsdutils core package which contains "logger", has version 2.20.1 installed and that version silently ignores the -n switch. This is what I found out:

  • All newer versions of logger from 2.21 to 2.24 build and work fine.
  • Version 2.20.1 builds fine but ignores the -n switch just like the installed version.
  • All Ubuntu from 12.04 up to including "trusty" all contain 2.20.1 :(

SOLUTION:

Get the latest util-linux from: ftp://ftp.kernel.org/pub/linux/utils/util-linux/

Unpack, ./configure, make, and copy the binary from ./misc-utils/logger to /usr/local/bin/logger.

You may have to refresh your shell such as "source ~/.bashrc" for the /usr/local/bin version to bite. Confirm the new logger is installed with "logger -V" where it should NOT say "logger from util-linux 2.20.1" anymore.