All Projects → apex → logs-winston

apex / logs-winston

Licence: MIT license
Apex Logs integration for the Node.js Winston logging framework

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to logs-winston

winston-dev-console
Winston@3 console format aimed to improve development UX
Stars: ✭ 88 (+300%)
Mutual labels:  winston-logger
winston-telegram
A Telegram transport for winston
Stars: ✭ 28 (+27.27%)
Mutual labels:  winston-transport
winston-loki
Grafana Loki transport for the nodejs logging library Winston.
Stars: ✭ 55 (+150%)
Mutual labels:  winston-transport
winston-slack-webhook-transport
A Slack transport for Winston 3 that logs to a channel via webhooks
Stars: ✭ 21 (-4.55%)
Mutual labels:  winston-transport
graphql-compose-elasticsearch
Graphql App using Node with typescript, KOA framework and Elasticsearch
Stars: ✭ 40 (+81.82%)
Mutual labels:  winston-logger

Apex Logs transport for the popular Winston Node.js logging framework.

Installation

npm install --save apex-logs-winston

Usage

Logs are buffered in memory and flushed periodically for more efficient ingestion. By default a maxEntries of 250, and flushInterval of 5 seconds (5000) are used.

const ApexLogsTransport = require('apex-logs-winston')
const winston = require('winston')

const apex = new ApexLogsTransport({
  url: process.env.APEX_LOGS_URL,
  authToken: process.env.APEX_LOGS_AUTH_TOKEN,
  projectId: process.env.APEX_LOGS_PROJECT_ID,
})

const logger = winston.createLogger({
  levels: winston.config.syslog.levels,
  transports: [apex],
  defaultMeta: { program: 'api', host: 'api-01' }
})

logger.info('User Login', { user: { name: 'Tobi Ferret' } })

Here's an example tuning the default buffering options:

const apex = new ApexLogsTransport({
  url: process.env.APEX_LOGS_URL,
  authToken: process.env.APEX_LOGS_AUTH_TOKEN,
  projectId: process.env.APEX_LOGS_PROJECT_ID
  buffer: { maxEntries: 100, flushInterval: 5000 }
})

Heroku & AWS Lambda

Services such as Heroku and AWS Lambda expect logs to be written to stdout, in these cases use json: true to simple output an Apex Logs-friendly JSON format:

const apex = new ApexLogsTransport({ json: true })

Note that the other options do not apply in this situation.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].