5

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?

2 Answers 2

8

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.

0

Just for support to Dennis Williamson's answer

simply read file and write to syslog daemon

You must log in to answer this question.

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