2

So I want to setup a nodejs process to listen and record the log files of my Apache2 server. I know there is a way to 'pipe' the log file to a script, but I cant seem to get it to work.

I have created a file called 'noder' which has the following code:

#!/usr/local/bin/node

var stdin  = process.stdin;
var fs     = require('fs');

stdin.resume();

stdin.on('data', function (chunk) {
     fs.writeFileSync('./output.log',chunk.toString());
}).on('end', function () {
     console.log('stdin:closed exiting');
});

It simply writes the stdin to a text file.

I also set my httpd.conf setting to the following:

CustomLog |/tmp/noder logstash_json
  • fyi: logstash_json is just a custom format I created, it works logging to a normal file.

I have tried all kinds of different formats in the httpd.conf file and nothing seems to work.

Thanks!

1 Answer 1

2

After some more working and banding my head on the desk, I finally figured it out:

CustomLog "|/usr/local/bin/node /nodelogger/noder" logstash_json

Thanks,

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.