syslog-appender-pro
v1.0.2
Published
Syslog Appender for TCP/TLS/UDP connections
Downloads
2
Maintainers
Readme
About
The syslog protocol (rfc5424) client. Works with Node.js over udp (rfc5426), tcp (rfc6587) and tls (rfc5425)
Documentation
Installation
npm
npm install syslog-appender-pro --save
Usage
- TCP
const { Appender, FACILITIES, SEVERITIES, PROTOCOLS } = require('syslog-appender-pro');
const logger = new Appender({
defaultAppName: 'syslog-appender-pro',
defaultStructuredData: {
'8bf8cc10-4140-4c3e-a2b4-e6f5324f1aea@41058': {
tag: PROTOCOLS.TCP,
},
},
host: 'logs-01.loggly.com',
port: 514,
protocol: PROTOCOLS.TCP,
facility: FACILITIES.LOCAL0,
severity: SEVERITIES.DEBUG
})
logger.debug({ message: 'Message from syslog-appender-pro!' })
.then((result) => {
console.log('Sent message on tcp');
})
.catch(console.error);
- TLS
const { Appender, FACILITIES, SEVERITIES, PROTOCOLS } = require('syslog-appender-pro');
const logger = new Appender({
defaultAppName: 'syslog-appender-pro',
caPath: '/etc/ssl/CA.crt',
certificatePath: '/etc/ssl/client.crt',
keyPath: '/etc/ssl/client.key',
defaultStructuredData: {
'8bf8cc10-4140-4c3e-a2b4-e6f5324f1aea@41058': {
tag: PROTOCOLS.TLS,
},
},
host: 'logs-01.loggly.com',
port: 514,
protocol: PROTOCOLS.TLS,
facility: FACILITIES.LOCAL0,
severity: SEVERITIES.DEBUG
})
logger.debug({ message: 'Message from syslog-appender-pro!' })
.then((result) => {
console.log('Sent message on tcp');
})
.catch(console.error);
- UDP
const { Appender, FACILITIES, SEVERITIES, PROTOCOLS } = require('syslog-appender-pro');
const logger = new Appender({
defaultAppName: 'syslog-appender-pro',
defaultStructuredData: {
'8bf8cc10-4140-4c3e-a2b4-e6f5324f1aea@41058': {
tag: POTOCOLS.UDP,
},
},
host: 'logs-01.loggly.com',
port: 514,
protocol: PROTOCOLS.UDP,
facility: FACILITIES.LOCAL0,
severity: SEVERITIES.DEBUG
})
logger.debug({ message: 'Message from syslog-appender-pro!' })
.then((result) => {
console.log('Sent message on udp');
})
.catch(console.error);
Options
Server Options
caPath
Exact path to ca certificate. Default: ''.certificatePath
Exact path to client certificate. Default: ''.keyPath
Exact path to key file. Default: ''.host
Doomain name or IP of host server. Defaut: 'localhost'.port
Port of host server. Default: 514.hostname
System hostname. Default: os.hostname().rejectUnauthorized
If true, the server certificate is verified against the list of supplied CAs. An error event is emitted if verification fails. Default: false.protocol
Protocol over which syslog is accepted by host server. Default: 'tcp'.
Appender Options
defaultAppName
Name of your application. Default: 'syslog-appender-pro'.defaultEol
Default end of line for syslogs. Default: '\n'.defaultFacility
Default Facility to be used for syslogs. Default: 'LOCAL0'.defaultSeverity
Default severity to be used for syslogs. Default: 'DEBUG'.defaultStructuredData
Default structured data if required for syslogs. Can be json format for logs, etc. Default: '-'.defaultMsgId
Default msgId for the syslogs. Default: '-'.
Severity
- ALERT
- CRITICAL
- DEBUG
- EMERGENCY
- ERROR
- INFORMATIONAL
- NOTICE
- WARNING
Facility
- LOCAL0
- LOCAL1
- LOCAL2
- LOCAL3
- LOCAL4
- LOCAL5
- LOCAL6
- LOCAL7