Star us on GitHub
Star
Menu

Logging in Winston

Learn how to set up highlight.io log ingestion for Winston JS.
1
Set up your frontend highlight.io integration.

First, make sure you've followed the frontend getting started guide.

2
Setup the Winston HTTP transport.

The Winston HTTP transport will send JSON logs to highlight.io

import {createLogger, format, transports} from 'winston'; const highlightTransport = new transports.Http({ host: 'pub.highlight.run', path: "/v1/logs/json", ssl: true, headers: { 'x-highlight-project': '<YOUR_PROJECT_ID>', 'x-highlight-service': 'EXAMPLE_NODEJS_SERVICE', }, }) export const logger = createLogger({ level: 'info', format: format.combine( format.json(), format.errors({ stack: true }), format.timestamp(), format.prettyPrint(), ), transports: [new transports.Console(), highlightTransport], })
Copy
3
Verify your backend logs are being recorded.

Visit the highlight logs portal and check that backend logs are coming in.