Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
$ 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?

share|improve this question
up vote 7 down vote accepted

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

-f 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.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .