{"id":22382352,"url":"https://github.com/jcoreio/log4jcore","last_synced_at":"2025-03-26T19:40:42.455Z","repository":{"id":29243710,"uuid":"110757872","full_name":"jcoreio/log4jcore","owner":"jcoreio","description":null,"archived":false,"fork":false,"pushed_at":"2024-03-11T06:23:13.000Z","size":2437,"stargazers_count":0,"open_issues_count":23,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-07T17:04:19.264Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","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/jcoreio.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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":"2017-11-14T23:42:02.000Z","updated_at":"2022-06-14T22:33:49.000Z","dependencies_parsed_at":"2025-02-01T01:41:14.869Z","dependency_job_id":"629e58f1-6315-4b6e-9857-83ebf22e8db9","html_url":"https://github.com/jcoreio/log4jcore","commit_stats":null,"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcoreio%2Flog4jcore","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcoreio%2Flog4jcore/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcoreio%2Flog4jcore/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcoreio%2Flog4jcore/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jcoreio","download_url":"https://codeload.github.com/jcoreio/log4jcore/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245726707,"owners_count":20662544,"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-12-05T00:12:37.544Z","updated_at":"2025-03-26T19:40:42.434Z","avatar_url":"https://github.com/jcoreio.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# log4jcore\n\nlog4jcore\n\n## Installation\n\n```sh\nyarn add log4jcore\n```\n\n## Usage\n\n```typescript\nimport { logger } from 'log4jcore'\n\nconst log = logger('MyClass')\n\nlog.info('starting application')\n\n// Multiple arguments are supported, like with console.log.\n// One benefit of this approach is that arguments are not\n// stringified unless the log level requires the message to be\n// logged.\nlog.info('ip address:', process.env.IP_ADDRESS)\n\n// Use arrow functions to avoid computing a message unless the\n// log level requires it to be logged.\nlog.debug(() =\u003e `hostname: ${process.env.HOSTNAME}`)\n```\n\n### Configuring Log Levels\n\nLog levels are set to `info` by default. To change the log level\nfor a logger, pass in an environment variable like `DEBUG=MyClass`.\n\nValid environment variable names are:\n\n- `TRACE`\n- `DEBUG`\n- `INFO`\n- `WARN`\n- `ERROR`\n- `FATAL`\n\nTo change the log levels of multiple loggers, use a comma separated list of logger\nnames, like `DEBUG=MyClass,AnotherClass`.\n\n### Changing Appenders\n\nThe default appender calls `console.log` if the message\nseverity is `WRAN` or lower, and calls `console.error` if the message severity\nis `ERROR` or higher.\n\n`setLogFunctionProvider` allows you to override this and replace the log writer\nwith a different one. This can be useful if you want to log to a file or log to\nan external logging API.\n\nYou can also pass custom providers to `createLogger`:\n\n```ts\nimport { createLogger, createDefaultLogProvider } from 'log4jcore'\nimport fs from 'fs'\nimport memoryLogProvider from 'log4jcore/memoryLogProvider'\nimport writableLogFunction from 'log4jcore/writableLogFunction'\n\nconst downstream = createLogger({ loggerPath: 'downstream' })\nconst memLog = memoryLogProvider()\nconst log = createLogger({\n  loggerPath: 'test',\n  logProviders: [\n    downstream.inputLogProvider,\n    memLog,\n    createDefaultLogProvider(\n      writableLogFunction(fs.createWriteStream('out.log'))\n    ),\n  ],\n})\n\n// later, you can inspect memLog.messages\n```\n\n#### Logging to a file using `log4jcore-file-appender`:\n\n`log4jcore-file-appender` is a simple logging provider that writes to a file instead\nof stdout / stderr. At the time of this writing, it does not have TypeScript type defs\nalthough it does have Flow Type defs.\n\n```sh\nyarn add log4jcore-file-appender\n```\n\n```js\nconst { setLogFunctionProvider } = require('log4jcore')\nconst { createFileAppender } = require('log4jcore-file-appender')\n\nsetLogFunctionProvider(createFileAppender({ file: 'messages.log' }))\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjcoreio%2Flog4jcore","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjcoreio%2Flog4jcore","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjcoreio%2Flog4jcore/lists"}