Log Aggregation

For aggregating logs from multiple sources, you can use tools like Fluentd, Logstash, or Graylog. Here’s how you might configure Winston to send logs to Fluentd:

npm install winston-fluentd

Then set up the transport:

const winston = require('winston');
const FluentTransport = require('winston-fluentd');

const logger = winston.createLogger({
  level: 'info',
  format: winston.format.combine(
winston.format.timestamp(),
winston.format.json()
), transports: [
new FluentTransport({
  host: 'localhost',
  port: 24224,
  timeout: 3.0,
  tag: 'app.log'
})
] }); logger.info('Log sent to Fluentd');

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *