Logging usage of Node.js-based services, with user privacy by design.
Visit resurface.io for general information on usage logging.
Requires Node.js 10.x or later. No other dependencies to conflict with your app.
npm install resurfaceio-logger --save
After installing the module, add a HttpLoggerForExpress
instance to your app, after any body parsers in use.
const express = require('express');
const app = express();
// add body parsers
const resurfaceio = require('resurfaceio-logger');
resurfaceio.HttpLoggerForExpress.add(app, {
url: 'https://...',
rules: 'include strict'
});
// define routes
After installing the module, add a HttpLoggerForExpress
instance before calling applyMiddleware
.
const app = express();
const resurfaceio = require('resurfaceio-logger');
resurfaceio.HttpLoggerForExpress.add(app, {
url: 'https://...',
rules: 'include strict'
});
const server = new ApolloServer({ ... });
server.applyMiddleware({ app });
After installing the module, create a logger and call it from the routes of interest.
const express = require('express');
const app = express();
const resurfaceio = require('resurfaceio-logger');
const logger = new resurfaceio.HttpLogger({
url: 'https://...',
rules: 'include strict'
});
app.get('/', function (request, response) {
response.render('pages/index', function (e, html) {
response.status(200).send(html);
resurfaceio.HttpMessage.send(logger, request, response, html);
});
});
Loggers can be directly integrated into your application using our API. This requires the most effort compared with the options described above, but also offers the greatest flexibility and control.
Loggers always have an active set of rules that control what data is logged and how sensitive data is masked. All of the examples above apply a predefined set of rules (include strict
), but logging rules are easily customized to meet the needs of any application.
Author: resurfaceio
Source Code: https://github.com/resurfaceio/logger-nodejs
#nodejs #node #javascript