Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/apex/logs-winston
Apex Logs integration for the Node.js Winston logging framework
https://github.com/apex/logs-winston
apex-logs logging nodejs winston-logger winston-transport
Last synced: about 2 months ago
JSON representation
Apex Logs integration for the Node.js Winston logging framework
- Host: GitHub
- URL: https://github.com/apex/logs-winston
- Owner: apex
- License: mit
- Created: 2020-07-13T14:12:02.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-08-31T09:45:29.000Z (over 4 years ago)
- Last Synced: 2024-05-21T07:26:08.859Z (8 months ago)
- Topics: apex-logs, logging, nodejs, winston-logger, winston-transport
- Language: JavaScript
- Homepage:
- Size: 13.7 KB
- Stars: 23
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
- Changelog: History.md
- License: LICENSE
Awesome Lists containing this project
README
[Apex Logs](https://apex.sh/logs/) transport for the popular [Winston](https://github.com/winstonjs/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.
```js
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:
```js
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:
```js
const apex = new ApexLogsTransport({ json: true })
```Note that the other options do not apply in this situation.