{"id":19257264,"url":"https://github.com/logzio/winston-logzio","last_synced_at":"2025-04-04T23:09:27.292Z","repository":{"id":2843644,"uuid":"47332322","full_name":"logzio/winston-logzio","owner":"logzio","description":"a winston transport wrapper for logzio","archived":false,"fork":false,"pushed_at":"2024-12-25T09:19:07.000Z","size":336,"stargazers_count":18,"open_issues_count":10,"forks_count":24,"subscribers_count":18,"default_branch":"master","last_synced_at":"2025-03-28T22:14:15.289Z","etag":null,"topics":["integration","logzio","nodejs-logger","winston","winston-transport"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/logzio.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-12-03T13:02:20.000Z","updated_at":"2024-12-25T09:18:02.000Z","dependencies_parsed_at":"2024-05-02T15:28:29.116Z","dependency_job_id":"93808445-9643-46ea-b627-fb6b99d6d509","html_url":"https://github.com/logzio/winston-logzio","commit_stats":{"total_commits":90,"total_committers":31,"mean_commits":2.903225806451613,"dds":0.8555555555555556,"last_synced_commit":"64c5d8f280f471a9f8318775d0fcbb3b0ccc5b48"},"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/logzio%2Fwinston-logzio","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/logzio%2Fwinston-logzio/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/logzio%2Fwinston-logzio/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/logzio%2Fwinston-logzio/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/logzio","download_url":"https://codeload.github.com/logzio/winston-logzio/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246959064,"owners_count":20860876,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["integration","logzio","nodejs-logger","winston","winston-transport"],"created_at":"2024-11-09T19:09:16.485Z","updated_at":"2025-04-04T23:09:27.273Z","avatar_url":"https://github.com/logzio.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"![Build Status](https://travis-ci.org/logzio/winston-logzio.svg?branch=master)\n\n# winston-logzio\n\nwinston-logzio is a winston plugin and wrapper for the logzio-nodejs appender. With winston-logzio, you can take advantage of the winston logger framework with your Node.js app.\n\n### Versions\n\nSupports Winston 3, If you want to use Winston 2 - Checkout v1.0.8\n\n### Add the dependency to your project\n\n```bash\nnpm install winston-logzio --save\n```\n\n## Configure winston-logzio\n\nUse the samples in the code block below as a starting point, and replace the sample with a configuration that matches your needs.  \nTo run with **Typescript** [click here](#typescript).\n\n```javascript\nconst winston = require('winston');\nconst LogzioWinstonTransport = require('winston-logzio');\n\nconst logzioWinstonTransport = new LogzioWinstonTransport({\n    level: 'info',\n    name: 'winston_logzio',\n    token: '\u003c\u003cSHIPPING-TOKEN\u003e\u003e',\n    host: '\u003c\u003cLISTENER-HOST\u003e\u003e',\n});\n\nconst logger = winston.createLogger({\n    format: winston.format.simple(),\n    transports: [logzioWinstonTransport],\n});\n\nlogger.log('warn', 'Just a test message');\n```\n\nReplace `\u003c\u003cSHIPPING-TOKEN\u003e\u003e` with your own logz.io logs shipping [token](https://app.logz.io/#/dashboard/settings/general).\u003cbr/\u003e\nReplace `\u003c\u003cLISTENER-HOST\u003e\u003e` with your [region’s listener host](https://docs.logz.io/user-guide/accounts/account-region.html) (for example, listener.logz.io). \u003c/br\u003e  \nFor more parameters for LogzioWinstonTransport and configuration options see our [docs](https://docs.logz.io/shipping/log-sources/nodejs.html). \u003c/br\u003e\nIf you do not have a [Logz.io](http://logz.io) account, you can sign up for a free trial [here](https://app.logz.io/#/signup)\n\n## Options\n\n-   **token**\n    Mandatory. Your account token. Look it up in the Device Config tab in Logz.io\n-   **type** - Log type. Help classify logs into different classifications\n-   **protocol** - `http`, `https` or `udp`. Default: `http`\n-   **host** - Destination host name. Default: `listener.logz.io`\n-   **port** - Destination port. Default port depends on protocol. For `udp` default port is `5050`, for `http` is `8070` and `8071` is for `https`\n-   **sendIntervalMs** - Time in milliseconds to wait between retry attempts. Default: `2000` (2 sec)\n-   **bufferSize** - The maximum number of messages the logger will accumulate before sending them all as a bulk. Default: `100`.\n-   **numberOfRetries** - The maximum number of retry attempts. Default: `3`\n-   **debug** - Should the logger print debug messages to the console? Default: `false`\n-   **callback** - A callback function called when an unrecoverable error has occured in the logger. The function API is: function(err) - err being the Error object.\n-   **timeout** - The read/write/connection timeout in milliseconds.\n-   **addTimestampWithNanoSecs** - Add a timestamp with nano seconds granularity. This is needed when many logs are sent in the same millisecond, so you can properly order the logs in kibana. The added timestamp field will be `@timestamp_nano` Default: `false`\n- **addOtelContext** - Add `trace_id`, `span_id`, `service_name` fields to logs when opentelemetry context is available.  Default: `true`\n-   **compress** - If true the the logs are compressed in gzip format. Default: `false`\n-   **internalLogger** - set internal logger that supports the function log. Default: console.\n-   **setUserAgent** - Set to `false` to send logs without the user-agent field in the request header. Default:`true`. If you want to send data from Firefox browser, set that option to `false`.\n-   **extraFields** - Adds your own custom fields to each log. Add in JSON Format, for example: `extraFields : { field_1: \"val_1\", field_2: \"val_2\" , ... }`.\n\n### Details\n\nThis winston plugin, basically just wraps our [nodejs logzio shipper](https://github.com/logzio/logzio-nodejs).\u003cbr/\u003e\nIf you want to configure the nodejs logger, any parameters sent to winston when initializing the transport\n(what is held in the variable `LogzioWinstonTransport` in the sample above) will be passed to the logzio nodejs logger itself.\n\n### Logs in my console\n\nThe winston logger by default sends all logs to the console.  \nYou can easily disable this by adding this line to your code :\n\n```js\nwinston.remove(winston.transports.Console);\n```\n\n\u003cdiv id=\"typescript\"\u003e\n\n## Running with Typescript\n\nIf you don't have a 'tsconfig.json' file start by running:\n\n```\ntsc --init\n```\n\nOn your 'tsconfig' file, under 'compilerOptions' make sure you have 'esModuleInterop' flag with the value 'true' or add it this way:\n\n```\n  \"compilerOptions\": {\n    ...\n    \"esModuleInterop\": true\n  }\n```\n\nCode sample:\n\n```\nimport winston from 'winston';\nimport LogzioWinstonTransport from 'winston-logzio';\n\nconst logzioWinstonTransport = new LogzioWinstonTransport({\n  level: 'info',\n  name: 'winston_logzio',\n   token: '\u003c\u003cSHIPPING-TOKEN\u003e\u003e',\n  host: '\u003c\u003cLISTENER-HOST\u003e\u003e',\n});\n\n\nconst logger = winston.createLogger({\n    format: winston.format.simple(),\n    transports: [logzioWinstonTransport],\n});\n\nlogger.log('warn', 'Just a test message');\n```\n\nReplace `\u003c\u003cSHIPPING-TOKEN\u003e\u003e` with your own logz.io logs shipping [token](https://app.logz.io/#/dashboard/settings/general).\u003cbr/\u003e\nReplace `\u003c\u003cLISTENER-HOST\u003e\u003e` with your [region’s listener host](https://docs.logz.io/user-guide/accounts/account-region.html) (for example, listener.logz.io). \u003cbr/\u003e\n\nFor more parameters for LogzioWinstonTransport and configuration options see our [docs](https://docs.logz.io/shipping/log-sources/nodejs.html).\u003cbr/\u003e\nFor trouble shooting press [here](#trouble-shooting).\u003cbr/\u003e\nIf you do not have a [Logz.io](http://logz.io) account, you can sign up for a free trial [here](https://app.logz.io/#/signup).\n\n**Note:** If winston-logzio is used as part of a serverless service (AWS Lambda, Azure Functions, Google Cloud Functions, etc.), add `logger.close()` at the end of the run.\n\n### Details\n\nThis winston plugin, basically just wraps our [nodejs logzio shipper](https://github.com/logzio/logzio-nodejs).\u003cbr/\u003e\nIf you want to configure the nodejs logger, any parameters sent to winston when initializing the transport\n(what is held in the variable `LogzioWinstonTransport` in the sample above) will be passed to the logzio nodejs logger itself.\n\n### Logs in my console\n\nThe winston logger by default sends all logs to the console.  \nYou can easily disable this by adding this line to your code :\n\n```js\nwinston.remove(winston.transports.Console);\n```\n\n\u003cdiv id=\"trouble-shooting\"\u003e\n\n# Troubleshooting\n\nTo fix errors related to \"esModuleInterop\" flag make sure you run the relavent 'tsconfig' file.\nThese might help:\n\n```\ntsc \u003cfile-name\u003e.ts --esModuleInterop\n```\n\nor\n\n```\ntsc --project tsconfig.json\n```\n\n\u003c/div\u003e\n\n\u003c/div\u003e\n\n## Add opentelemetry context\nIf you're sending traces with OpenTelemetry instrumentation (auto or manual), you can correlate your logs with the trace context. That way, your logs will have traces data in it, such as service name, span id and trace id (version \u003e= `5.2.0`). \n\nThis feature is enabled by default, To disable it, set the `AddOtelContext` param in your handler configuration to `false`, like in this example:\n\n```javascript\nconst winston = require('winston');\nconst LogzioWinstonTransport = require('winston-logzio');\n\nconst logzioWinstonTransport = new LogzioWinstonTransport({\n    level: 'info',\n    name: 'winston_logzio',\n    token: '\u003c\u003cSHIPPING-TOKEN\u003e\u003e',\n    host: '\u003c\u003cLISTENER-HOST\u003e\u003e',\n    addOtelCotext: false,\n});\n\nconst logger = winston.createLogger({\n    format: winston.format.simple(),\n    transports: [logzioWinstonTransport],\n});\n```\n\n## Build and test locally\n1. Clone the repository:\n  ```bash\n  git clone https://github.com/logzio/winston-logzio.git\n  cd winston-logzio\n  ```\n2. Build and run tests:\n  ```bash\n  npm install\n  npm test\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flogzio%2Fwinston-logzio","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flogzio%2Fwinston-logzio","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flogzio%2Fwinston-logzio/lists"}