syslog-logger
A node.js module for logging messages to the syslog on Unix-based systems.
It relies node-posix to make the system call.
General usage
- Installation:
npm install syslog-logger
- In your code:
var logger = require('syslog-logger');
- Logging:
logger.logInfo('Format %s are expected: %d', 'strings', 1000 );
- logEmergency, logAlert, logCritical, logError, logWarning, logNotice and logDebug are also available
Initialization options
-
Example:
var logger = require('syslog-logger').init( { appName: 'name of app', showPID: true });
-
Calling init is not necessary, provides the following defaults:
- appName: the second argument to the current process usually a .js file name, falls back to to process.title
- showPID: false
- nDelay: true
- facility: 'local0'
- maxSyslogLevel: 'notice'
-
All the options explained:
- appName: app-name in the syslog
- showPID: whether to show process PID (shows up in the same field as app-name)
- nDelay: Open the connection immediately (normally, the connection is opened when the first message is logged).
- facility: Surprisingly enough, this makes to the facility argument to syslog
- maxSyslogLevel: the maximum level (emerg=0 to debug=7) that will be logged to syslog. Messages below this level will be written to the console, but not to syslog.