Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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

2 Answers 2

up vote 11 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. –  bdowning 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

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.