{"id":18278197,"url":"https://github.com/log4js-node/logstashudp","last_synced_at":"2025-04-05T04:31:04.779Z","repository":{"id":30083481,"uuid":"123857958","full_name":"log4js-node/logstashUDP","owner":"log4js-node","description":"LogstashUDP Appender for log4js","archived":false,"fork":false,"pushed_at":"2023-10-19T16:24:07.000Z","size":1011,"stargazers_count":19,"open_issues_count":3,"forks_count":4,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-20T22:18:38.129Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/log4js-node.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-03-05T03:12:17.000Z","updated_at":"2024-12-26T09:23:48.000Z","dependencies_parsed_at":"2024-06-18T18:14:29.264Z","dependency_job_id":"e3bc50a8-ce8e-405b-94c5-e70807591907","html_url":"https://github.com/log4js-node/logstashUDP","commit_stats":{"total_commits":30,"total_committers":4,"mean_commits":7.5,"dds":0.5666666666666667,"last_synced_commit":"c4b71e8657a366d9489367e78a7eac2cc5f1378b"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/log4js-node%2FlogstashUDP","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/log4js-node%2FlogstashUDP/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/log4js-node%2FlogstashUDP/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/log4js-node%2FlogstashUDP/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/log4js-node","download_url":"https://codeload.github.com/log4js-node/logstashUDP/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247289382,"owners_count":20914463,"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":[],"created_at":"2024-11-05T12:23:26.314Z","updated_at":"2025-04-05T04:30:59.749Z","avatar_url":"https://github.com/log4js-node.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Log4JS - Logstash UDP appender\n\nThis is an optional appender for [log4js-node](https://log4js-node.github.io/log4js-node/).\n```bash\nnpm install @log4js-node/logstashudp\n```\n\nThe logstashUDP appender supports sending log events to a [Logstash](https://www.elastic.co/products/logstash) server. It uses the node.js core UDP support, and so requires no extra dependencies. Remember to call `log4js.shutdown` in your application if you want the UDP socket closed cleanly.\n\n## Configuration\n\n* `type` - `@log4js-node/logstashudp`\n* `host` - `string` - hostname (or IP-address) of the logstash server\n* `port` - `integer` - port of the logstash server\n* `layout` - (optional, defaults to dummyLayout) - used for the message field of the logstash data (see layouts)\n* `extraDataProvider` - function (optional, defaults to put the second param of log to fields) - used to enhance the object sent to Logstash via UDP. this will be passed the log event and should return a object.\n\n## Example\n### default config\n```javascript\nlog4js.configure({\n  appenders: {\n    logstash: {\n      type: '@log4js-node/logstashudp',\n      host: 'log.server',\n      port: 12345\n    }\n  },\n  categories: {\n    default: { appenders: ['logstash'], level: 'info' }\n  }\n});\nconst logger = log4js.getLogger();\nlogger.info(\"important log message\", { cheese: 'gouda', biscuits: 'hobnob' });\n```\nThis will result in a JSON message being sent to log.server:12345 over UDP, with the following format:\n```javascript\n{\n  '@version': '1',\n  '@timestamp': '2014-04-22T23:03:14.111Z',\n  'host': 'yourHostname',\n  'level': 'INFO',\n  'category': 'default',\n  'message': 'important log message',\n  'fields': {\n    'biscuits': 'hobnob',\n    'cheese': 'gouda'\n  }\n}\n```\n### use estraDataProvider\n```javascript\nlog4js.configure({\n  appenders: {\n    logstash: {\n      type: '@log4js-node/logstashudp',\n      host: 'log.server',\n      port: 12345,\n      extraDataProvider: loggingEvent =\u003e ({\n        host: 'anotherHostname',  // this will replace the default real host\n        clientIp: '1.2.3.4', // this will be added\n        fields: {\n          tag: 'myTag', // this will be added to the fields\n          pid: loggingEvent.pid, // this will be added to the fields\n          cheese: 'defaultCheese' // this will be added to the fields but will not be replaced in this example\n        }\n      })\n    }\n  },\n  categories: {\n    default: { appenders: ['logstash'], level: 'info' }\n  }\n});\nconst logger = log4js.getLogger();\nlogger.info(\"important log message\", { cheese: 'gouda', biscuits: 'hobnob' });\n```\nThis will result in a JSON message being sent to log.server:12345 over UDP, with the following format:\n```javascript\n{\n  '@version': '1',\n  '@timestamp': '2014-04-22T23:03:14.111Z',\n  'host': 'anotherHostname',\n  'level': 'INFO',\n  'category': 'default',\n  'message': 'important log message',\n  'clientIp': '1.2.3.4',\n  'fields': {\n    'cheese': 'defaultCheese',\n    'tag': 'myTag',\n    'pid': 123\n  }\n}\n```\nSo, if not using the default `extraDataProvider`, you have to put the second param of the log to the fields yourself if you want.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flog4js-node%2Flogstashudp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flog4js-node%2Flogstashudp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flog4js-node%2Flogstashudp/lists"}