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!