Content translation/cxserver/Logging
cxserver uses bunyan for logging. It can simply log to stdout or it can even log to a logstash instance through gelf-stream. The logging is configurable in cxserver configuration. You can define multiple logging streams. A simple stdout logging stream is
{ level: 'debug', stream: process.stdout }
A gelf stream can be
{
// Use gelf-stream -> logstash
type: 'gelf',
host: 'localhost', // host where logstash with gelf input plugin is running
port: 12201, // port of host where logstash with gelf input plugin is running
level: 'info' // log INFO and above to gelf
}
To use such a gelf stream you need to have a working and running logstash with gelf input plugin
The steps to setup a logstash instance is given below briefly
- Install logstash
- Create a gelf input plugin configuration. For this create a file named gelf-agent.conf with following content. The output section is optional. It helps you to get logs in a file too. It is possible to configure to use elastic search and all. Read the logstash documentation for this.
input {
gelf{
host => localhost
}
}
output {
file {
path => "./path/to/test-%{+YYYY-MM-dd}.txt"
}
}
Run logstash
bin/logstash -v -f gelf-agent.conf
Now restart cxserver and you should see the log getting added to the log file added to the output section of about configuration