Provides an HTTP appender for log4js2 that pushes log events to a server endpoint via a POST
call.
If you're building from source, simply run
> npm install
> npm run build
Or, you can install the appender from npm.
> npm install --save @log4js2/http-appender
Configure the appender using the configure()
method.
import {configure, LogLevel} from '@log4js2/core';
import {HttpAppender} from '@log4js2/http-appender';
configure({
level: LogLevel.INFO
layout: '%d [%p] %c %M:%line:%column - %m %ex',
appenders: ['Console', {
name: 'Http',
appender: HttpAppender,
config: {
url: '/log-endpoint'
}
}],
loggers: [{
tag: 'App',
logLevel : LogLevel.INFO,
appenders: ['Http']
}]
});
Note: because posting via HTTP can be intensive, it is a good idea to ensure your appender is only receiving logs from appropriate loggers.
Library built and maintained by Robin Schultz
If you would like to contribute (aka buy me a beer), you can send funds via PayPal at the link below.