{"id":13396746,"url":"https://github.com/log4js-node/log4js-node","last_synced_at":"2025-05-13T18:04:56.341Z","repository":{"id":782906,"uuid":"475599","full_name":"log4js-node/log4js-node","owner":"log4js-node","description":"A port of log4js to node.js","archived":false,"fork":false,"pushed_at":"2024-07-25T11:31:07.000Z","size":3884,"stargazers_count":5827,"open_issues_count":95,"forks_count":767,"subscribers_count":110,"default_branch":"master","last_synced_at":"2025-05-06T16:17:27.316Z","etag":null,"topics":["javascript","log4js-node"],"latest_commit_sha":null,"homepage":"https://log4js-node.github.io/log4js-node/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/log4js-node.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2010-01-17T00:57:58.000Z","updated_at":"2025-04-19T17:13:25.000Z","dependencies_parsed_at":"2023-02-10T14:00:16.270Z","dependency_job_id":"fcf58361-25f1-4761-a074-b7931ed4bbf7","html_url":"https://github.com/log4js-node/log4js-node","commit_stats":{"total_commits":1652,"total_committers":189,"mean_commits":8.74074074074074,"dds":0.7518159806295399,"last_synced_commit":"26dcec62f9677dceba57de8cd717ff91447781c7"},"previous_names":["nomiddlename/log4js-node"],"tags_count":129,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/log4js-node%2Flog4js-node","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/log4js-node%2Flog4js-node/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/log4js-node%2Flog4js-node/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/log4js-node%2Flog4js-node/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/log4js-node","download_url":"https://codeload.github.com/log4js-node/log4js-node/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253365425,"owners_count":21897184,"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":["javascript","log4js-node"],"created_at":"2024-07-30T18:01:01.768Z","updated_at":"2025-05-13T18:04:56.296Z","avatar_url":"https://github.com/log4js-node.png","language":"JavaScript","readme":"# log4js-node [![CodeQL](https://github.com/log4js-node/log4js-node/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/log4js-node/log4js-node/actions/workflows/codeql-analysis.yml) [![Node.js CI](https://github.com/log4js-node/log4js-node/actions/workflows/node.js.yml/badge.svg)](https://github.com/log4js-node/log4js-node/actions/workflows/node.js.yml)\n\n[![NPM](https://nodei.co/npm/log4js.png?downloads=true\u0026downloadRank=true\u0026stars=true)](https://nodei.co/npm/log4js/)\n\nThis is a conversion of the [log4js](https://github.com/stritti/log4js)\nframework to work with [node](http://nodejs.org). I started out just stripping out the browser-specific code and tidying up some of the javascript to work better in node. It grew from there. Although it's got a similar name to the Java library [log4j](https://logging.apache.org/log4j/2.x/), thinking that it will behave the same way will only bring you sorrow and confusion.\n\nThe full documentation is available [here](https://log4js-node.github.io/log4js-node/).\n\n[Changes in version 3.x](https://log4js-node.github.io/log4js-node/v3-changes.md)\n\nThere have been a few changes between log4js 1.x and 2.x (and 0.x too). You should probably read this [migration guide](https://log4js-node.github.io/log4js-node/migration-guide.html) if things aren't working.\n\nOut of the box it supports the following features:\n\n- coloured console logging to stdout or stderr\n- file appender, with configurable log rolling based on file size or date\n- a logger for connect/express servers\n- configurable log message layout/patterns\n- different log levels for different log categories (make some parts of your app log as DEBUG, others only ERRORS, etc.)\n\nOptional appenders are available:\n\n- [SMTP](https://github.com/log4js-node/smtp)\n- [GELF](https://github.com/log4js-node/gelf)\n- [Loggly](https://github.com/log4js-node/loggly)\n- Logstash ([UDP](https://github.com/log4js-node/logstashUDP) and [HTTP](https://github.com/log4js-node/logstashHTTP))\n- logFaces ([UDP](https://github.com/log4js-node/logFaces-UDP) and [HTTP](https://github.com/log4js-node/logFaces-HTTP))\n- [RabbitMQ](https://github.com/log4js-node/rabbitmq)\n- [Redis](https://github.com/log4js-node/redis)\n- [Hipchat](https://github.com/log4js-node/hipchat)\n- [Slack](https://github.com/log4js-node/slack)\n- [mailgun](https://github.com/log4js-node/mailgun)\n- [InfluxDB](https://github.com/rnd-debug/log4js-influxdb-appender)\n\n## Getting help\n\nHaving problems? Jump on the [slack](https://join.slack.com/t/log4js-node/shared_invite/enQtODkzMDQ3MzExMDczLWUzZmY0MmI0YWI1ZjFhODY0YjI0YmU1N2U5ZTRkOTYyYzg3MjY5NWI4M2FjZThjYjdiOGM0NjU2NzBmYTJjOGI) channel, or create an issue. If you want to help out with the development, the slack channel is a good place to go as well.\n\n## installation\n\n```bash\nnpm install log4js\n```\n\n## usage\n\nMinimalist version:\n\n```javascript\nvar log4js = require(\"log4js\");\nvar logger = log4js.getLogger();\nlogger.level = \"debug\";\nlogger.debug(\"Some debug messages\");\n```\n\nBy default, log4js will not output any logs (so that it can safely be used in libraries). The `level` for the `default` category is set to `OFF`. To enable logs, set the level (as in the example). This will then output to stdout with the coloured layout (thanks to [masylum](http://github.com/masylum)), so for the above you would see:\n\n```bash\n[2010-01-17 11:43:37.987] [DEBUG] [default] - Some debug messages\n```\n\nSee example.js for a full example, but here's a snippet (also in `examples/fromreadme.js`):\n\n```javascript\nconst log4js = require(\"log4js\");\nlog4js.configure({\n  appenders: { cheese: { type: \"file\", filename: \"cheese.log\" } },\n  categories: { default: { appenders: [\"cheese\"], level: \"error\" } },\n});\n\nconst logger = log4js.getLogger(\"cheese\");\nlogger.trace(\"Entering cheese testing\");\nlogger.debug(\"Got cheese.\");\nlogger.info(\"Cheese is Comté.\");\nlogger.warn(\"Cheese is quite smelly.\");\nlogger.error(\"Cheese is too ripe!\");\nlogger.fatal(\"Cheese was breeding ground for listeria.\");\n```\n\nOutput (in `cheese.log`):\n\n```bash\n[2010-01-17 11:43:37.987] [ERROR] cheese - Cheese is too ripe!\n[2010-01-17 11:43:37.990] [FATAL] cheese - Cheese was breeding ground for listeria.\n```\n\n## Note for library makers\n\nIf you're writing a library and would like to include support for log4js, without introducing a dependency headache for your users, take a look at [log4js-api](https://github.com/log4js-node/log4js-api).\n\n## Documentation\n\nAvailable [here](https://log4js-node.github.io/log4js-node/).\n\nThere's also [an example application](https://github.com/log4js-node/log4js-example).\n\n## TypeScript\n\n```ts\nimport * as log4js from \"log4js\";\nlog4js.configure({\n  appenders: { cheese: { type: \"file\", filename: \"cheese.log\" } },\n  categories: { default: { appenders: [\"cheese\"], level: \"error\" } },\n});\n\nconst logger = log4js.getLogger();\nlogger.level = \"debug\";\nlogger.debug(\"Some debug messages\");\n```\n\n## Contributing\n\nWe're always looking for people to help out. Jump on [slack](https://join.slack.com/t/log4js-node/shared_invite/enQtODkzMDQ3MzExMDczLWUzZmY0MmI0YWI1ZjFhODY0YjI0YmU1N2U5ZTRkOTYyYzg3MjY5NWI4M2FjZThjYjdiOGM0NjU2NzBmYTJjOGI) and discuss what you want to do. Also, take a look at the [rules](https://log4js-node.github.io/log4js-node/contrib-guidelines.html) before submitting a pull request.\n\n## License\n\nThe original log4js was distributed under the Apache 2.0 License, and so is this. I've tried to\nkeep the original copyright and author credits in place, except in sections that I have rewritten\nextensively.\n","funding_links":[],"categories":["日志","Utilities","JavaScript","Repository","Uncategorized","目录","1. 后端开发","node端","Logging"],"sub_categories":["Logging","Uncategorized","1.5 日志","建站"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flog4js-node%2Flog4js-node","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flog4js-node%2Flog4js-node","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flog4js-node%2Flog4js-node/lists"}