What does logger -f filename do?

4

0

The man page is ambiguously worded:

-f file    Log the specified file.

There's one example in the man page with no further explanation:

logger -p local0.notice -t HOSTIDM -f /dev/idmc

POSIX is no help:

The logger utility saves a message, in an unspecified manner and format, containing the string operands provided by the user. The messages are expected to be evaluated later by personnel performing system administration tasks.

I would expect it to log:

  • to the file
  • something about the file
  • or something from the file

However, if I do the following:

$ echo "contents" > testfile
$ logger -f ./testfile "test message"
$ cat testfile
contents
$ tail /var/log/messages
Aug  4 10:00:00 hostname logger: test message

I get nothing having to do with "testfile" or its contents nor are its contents changed. If testfile doesn't exist before I issue the logger command I get this error message:

logger: ./testfile: No such file or directory.

What is logger -f supposed to do?

Paused until further notice.

Posted 2010-08-04T15:19:54.373

Reputation: 86 075

Answers

7

The GNU documentation is a little clearer and provided a hint for further testing:

-f file
--file=file
Log the content of the specified file. If file is ‘-’ the standard input is assumed.

It turns out that specifying a message overrides the specification of a file.

So this works:

logger -f testfile

and logs the contents of the file to the logfile. If the file consists of multiple lines, each line becomes a separate entry in the log.

Paused until further notice.

Posted 2010-08-04T15:19:54.373

Reputation: 86 075