{"id":25758078,"url":"https://github.com/anubisss/winston-json-log-formatter","last_synced_at":"2026-05-13T11:35:03.531Z","repository":{"id":57398067,"uuid":"260963816","full_name":"Anubisss/winston-json-log-formatter","owner":"Anubisss","description":"A simple winston JSON log formatter.","archived":false,"fork":false,"pushed_at":"2020-05-03T18:05:05.000Z","size":4,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-08-09T05:48:10.598Z","etag":null,"topics":["format","formatter","json","logger","winston"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/winston-json-log-formatter","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Anubisss.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-05-03T15:44:37.000Z","updated_at":"2022-04-01T08:26:24.000Z","dependencies_parsed_at":"2022-09-04T13:10:28.572Z","dependency_job_id":null,"html_url":"https://github.com/Anubisss/winston-json-log-formatter","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Anubisss%2Fwinston-json-log-formatter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Anubisss%2Fwinston-json-log-formatter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Anubisss%2Fwinston-json-log-formatter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Anubisss%2Fwinston-json-log-formatter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Anubisss","download_url":"https://codeload.github.com/Anubisss/winston-json-log-formatter/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240891794,"owners_count":19874253,"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":["format","formatter","json","logger","winston"],"created_at":"2025-02-26T16:37:05.574Z","updated_at":"2026-05-13T11:35:03.206Z","avatar_url":"https://github.com/Anubisss.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# winston-json-log-formatter\n[![npm version](https://badge.fury.io/js/winston-json-log-formatter.svg)](https://www.npmjs.com/package/winston-json-log-formatter)\n\nThis is a very simple Node.js module which creates a console transport (by default) for [winston](https://github.com/winstonjs/winston) to log messages in JSON format.\n\n## Requirements\n* Node.js \u003e= 8.3.0\n* winston@3\n\n## Install\n```npm install winston-json-log-formatter```\n\n## Usage/Features\nImport the module in your source code which imports winston also.\n```javascript\nconst winston = require('winston');\nconst wjlf = require('winston-json-log-formatter');\n```\n\nSetup the console transport which will log in JSON.\n```javascript\nwjlf.setupTransport(winston);\n```\n\nYou can log dates automatically.\n```javascript\nwjlf.setupTransport(winston, true);\n```\n\nAlso you can bind properties to every log message.\n```javascript\nwjlf.setupTransport(winston, false, { requestId: 'id' });\n```\n\nIf you want to use the formatter only then you can access it via ```wjlf.logFormatter```\n\n\nHow to log: just use winston.\n```javascript\nwinston.info('test message');\nwinston.info('message with meta object', { propertyOne: 1, propertyTwo: 'two' });\n```\n\n## Example Lambda handler function\n```javascript\n'use strict';\n\nconst winston = require('winston');\nconst wjlf = require('winston-json-log-formatter');\n\nconst handler = async (event, context) =\u003e {\n  wjlf.setupTransport(winston, true, { awsRequestId: context.awsRequestId, foo: 'bar' });\n\n  winston.log('info', 'starting', {\n    nodeVersion: process.version,\n    platform: process.platform,\n    architecture: process.arch,\n    timezoneOffset: new Date().getTimezoneOffset() / 60,\n  });\n\n  winston.info('test message');\n\n  winston.error('error occurred', {\n    error: {\n      message: 'ERR_MSG',\n      code: 145,\n    },\n  });\n\n  return 'ok';\n};\n\nmodule.exports = {\n  handler,\n};\n```\n\nOutput log messages are filterable in AWS CloudWatch Logs.\n\n\nJSON\n```json\n{\"date\":\"2020-05-03T16:32:32.123Z\",\"level\":\"info\",\"message\":\"starting\",\"meta\":{\"nodeVersion\":\"v12.16.1\",\"platform\":\"linux\",\"architecture\":\"x64\",\"timezoneOffset\":0},\"awsRequestId\":\"fc121189-1778-40a0-882b-0f186f61285e\",\"foo\":\"bar\"}\n{\"date\":\"2020-05-03T16:32:32.160Z\",\"level\":\"info\",\"message\":\"test message\",\"awsRequestId\":\"fc121189-1778-40a0-882b-0f186f61285e\",\"foo\":\"bar\"}\n{\"date\":\"2020-05-03T16:32:32.160Z\",\"level\":\"error\",\"message\":\"error occurred\",\"meta\":{\"error\":{\"message\":\"ERR_MSG\",\"code\":145}},\"awsRequestId\":\"fc121189-1778-40a0-882b-0f186f61285e\",\"foo\":\"bar\"}\n```\n\nAWS CloudWatch Logs\n![AWS CloudWatch Logs](https://i.imgur.com/bZnRmye.png)\n\n## License\nThe MIT License (MIT)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanubisss%2Fwinston-json-log-formatter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fanubisss%2Fwinston-json-log-formatter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanubisss%2Fwinston-json-log-formatter/lists"}