Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. 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

I have a Node.js server that is being monitored by forever. Forever generates three logfiles: the server STDOUT, STDERR and the log of forever itself.

$ forever -l forever.log -o out.log -e err.log app.js

But instead of logging to logfiles I would like to log everything to syslog, optionally with adding a prefix of some sorts so my syslog processing servers can sort everything out.

On StackOverflow, someone suggested that this can be handled using some bash wrapper and suggested I ask here. So, how would I get those logs into syslog instead of into files?

share|improve this question
up vote 13 down vote accepted

Have you tried using logger with process substitution?

$ forever -a >(logger -t forever) -o >(logger -t app.js) -e >(logger -t app.js) app.js

You can play around with the logger -p switch for specifying log levels, warn, info, err, etc. as well as other logger switches. The forever -l needed to be changed to forever -a.

I tried this with a few of the sample files installed by forever and it worked. Each distro may log to different log file by default, you'll have to experiment with logger switches.

share|improve this answer
Thanks, that sounds perfect! I'll give it a try when I'm back at work on Monday. – Sander Marechal Mar 3 '12 at 17:45
@SanderMarechal Experiment with logger by itself, figure out which switches will help you, then modify the example to suit. Good luck. – bsd Mar 3 '12 at 17:53
Worked like a charm. Thanks! – Sander Marechal Mar 5 '12 at 7:44
This might have worked in the past, but now the -a option does not allow for an argument; i.e. the command must be `forever -a -o >(logger -t app.js) -e >(logger -t app.js) app.js' – radiospiel Oct 17 '14 at 14:21

With rsyslog you can use the Text File Input Module to monitor log files and process them.


share|improve this answer
Btw, syslog-ng apparently can do this, too. – sr_ Mar 2 '12 at 15:11
This is true, but log rotation is more involved this way because the application continues to hold the file descriptors open to log to them, possibly requiring the app to restarted when the logs are rotated. That's not an issue when logging directly to syslog via logger. – Mark Stosberg Jun 29 '15 at 13:25

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.