{"id":22891428,"url":"https://github.com/loglayer/loglayer","last_synced_at":"2026-04-02T20:53:10.412Z","repository":{"id":37941999,"uuid":"432001054","full_name":"loglayer/loglayer","owner":"loglayer","description":"A modern logging library for Javascript / Typescript that routes logs to various logging libraries, cloud providers, files, StatsD, and OpenTelemetry while providing a fluent API for specifying log messages, metadata and errors.","archived":false,"fork":false,"pushed_at":"2026-04-01T02:11:28.000Z","size":10318,"stargazers_count":473,"open_issues_count":1,"forks_count":9,"subscribers_count":3,"default_branch":"master","last_synced_at":"2026-04-01T04:21:57.619Z","etag":null,"topics":["abstraction","bun","datadog","deno","electron","file-rotation","javascript","log","log-rotation","logger","logging","logging-library","nextjs","nodejs","opentelemetry","pino","statsd","structured-logging","typescript","wrapper"],"latest_commit_sha":null,"homepage":"http://loglayer.dev/","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/loglayer.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":"AGENTS.md","dco":null,"cla":null}},"created_at":"2021-11-25T23:24:36.000Z","updated_at":"2026-04-01T02:10:28.000Z","dependencies_parsed_at":"2026-02-13T01:02:28.022Z","dependency_job_id":null,"html_url":"https://github.com/loglayer/loglayer","commit_stats":{"total_commits":89,"total_committers":3,"mean_commits":"29.666666666666668","dds":0.2134831460674157,"last_synced_commit":"ea5b9658404a6ca496e82e7be145edf8070b7127"},"previous_names":["loglayer/loglayer","theogravity/loglayer"],"tags_count":1454,"template":false,"template_full_name":"theogravity/boilerplate-typescript-old","purl":"pkg:github/loglayer/loglayer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loglayer%2Floglayer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loglayer%2Floglayer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loglayer%2Floglayer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loglayer%2Floglayer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/loglayer","download_url":"https://codeload.github.com/loglayer/loglayer/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loglayer%2Floglayer/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31316008,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-02T12:59:32.332Z","status":"ssl_error","status_checked_at":"2026-04-02T12:54:48.875Z","response_time":89,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["abstraction","bun","datadog","deno","electron","file-rotation","javascript","log","log-rotation","logger","logging","logging-library","nextjs","nodejs","opentelemetry","pino","statsd","structured-logging","typescript","wrapper"],"created_at":"2024-12-13T22:16:06.047Z","updated_at":"2026-04-02T20:53:10.407Z","avatar_url":"https://github.com/loglayer.png","language":"TypeScript","readme":"# LogLayer\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://loglayer.dev\" title=\"LogLayer Logo\"\u003e\u003cimg src=\"docs/src/public/images/loglayer.png\" alt=\"LogLayer Logo\" width=\"200\" /\u003e\u003c/a\u003e\n\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://www.npmjs.com/package/loglayer\"\u003e\u003cimg src=\"https://img.shields.io/npm/v/loglayer.svg?style=flat-square\" alt=\"NPM version\" /\u003e\u003c/a\u003e\n  \u003ca href=\"https://www.npmjs.com/package/loglayer\"\u003e\u003cimg src=\"https://img.shields.io/npm/dm/loglayer\" alt=\"NPM Downloads\" /\u003e\u003c/a\u003e\n  \u003ca href=\"http://www.typescriptlang.org/\"\u003e\u003cimg src=\"https://img.shields.io/badge/%3C%2F%3E-TypeScript-%230074c1.svg\" alt=\"TypeScript\" /\u003e\u003c/a\u003e\n  \u003cimg src=\"https://img.shields.io/bundlejs/size/loglayer\" alt=\"npm package minimized gzipped size\" /\u003e\n\u003c/p\u003e\n\n`loglayer` is a unified logger that routes logs to various logging libraries, cloud providers, files, and OpenTelemetry while providing a fluent API for specifying log messages, metadata and errors. \n\nSupports browser, Node.js, Bun, and Deno platforms.\n\nFor full documentation, read the [docs](https://loglayer.dev).\n\n```javascript\n// Example using the Pino logging library with LogLayer\n// You can also start out with a console logger and swap to another later!\nimport { LogLayer } from 'loglayer';\nimport { pino } from 'pino';\nimport { PinoTransport } from '@loglayer/transport-pino';\nimport { redactionPlugin } from '@loglayer/plugin-redaction';\n\nconst log = new LogLayer({\n  // Multiple loggers can also be used at the same time. \n  transport: new PinoTransport({\n    logger: pino()\n  }),\n  // Plugins modify log data before it's shipped to your logging library.\n  plugins: [\n    redactionPlugin({\n      paths: ['password'],\n      censor: '[REDACTED]',\n    }),\n  ],\n  // Put context data in a specific field (default is flattened)\n  contextFieldName: 'context',\n  // Put metadata in a specific field (default is flattened)\n  metadataFieldName: 'metadata',\n})\n\n// persisted data that is always included in logs\nlog.withContext({\n   path: \"/\",\n   reqId: \"1234\"\n})\n\nlog.withPrefix(\"[my-app]\")\n  .withError(new Error('test'))\n  // data that is included for this log entry only\n  .withMetadata({ some: 'data', password: 'my-pass' })\n  // Non-object data only (numbers, booleans, and strings only)\n  // this can be omitted to just log an object / error\n  // by using .errorOnly() / .metadataOnly() instead of withError() / withMetadata()\n  .info('my message')\n```\n\n```json5\n{\n   \"level\": 30,\n   \"time\": 1735857465669,\n   \"msg\": \"[my-app] my message\",\n   \"context\": {\n      \"path\": \"/\",\n      \"reqId\": \"1234\",\n   },\n   \"metadata\": {\n      \"password\": \"[REDACTED]\",\n      \"some\": \"data\",\n   },\n   \"err\":{\n      \"type\": \"Error\",\n      \"message\": \"test\",\n      \"stack\": \"Error: test\\n ...\"\n   }\n}\n```\n\nWith the [Pretty Terminal Transport](https://loglayer.dev/transports/pretty-terminal):\n\n![Pretty Terminal Transport](https://loglayer.dev/images/pretty-terminal/pretty-terminal-short-v2.gif)\n\nThe [Hot Shots Mixin](https://loglayer.dev/mixins/hot-shots) adds a metrics API to LogLayer:\n\n```typescript\nimport { LogLayer, useLogLayerMixin, ConsoleTransport } from 'loglayer';\nimport { StatsD } from 'hot-shots';\nimport { hotshotsMixin } from '@loglayer/mixin-hot-shots';\n\n// Create a StatsD client\nconst statsd = new StatsD({\n  host: 'localhost',\n  port: 8125\n});\n\n// Register the mixin (must be called before creating LogLayer instances)\nuseLogLayerMixin(hotshotsMixin(statsd));\n\n// Create LogLayer instance\nconst log = new LogLayer({\n  transport: new ConsoleTransport({\n    logger: console\n  })\n});\n\n// Use StatsD methods through the stats property\nlog.stats.increment('request.count').send();\nlog.info('Request received');\nlog.stats.timing('request.duration', 150).send();\nlog.info('Request processed');\nlog.stats.gauge('active.connections', 42).send();\nlog.info('Connection established');\n```\n\n## Development Setup\n\nThis is a monorepo using [`pnpm`](https://pnpm.io/installation) for package management and [`turbo`](https://turbo.build/repo/docs/getting-started/installation) for build orchestration. \nIf you're looking to contribute or work with the source code, follow these steps:\n\n1. Clone the repository\n2. Install dependencies:\n   ```bash\n   pnpm install\n   ```\n3. Install git hooks:\n    ```bash\n    pnpx lefthook install\n    ```\n4. Build all packages:\n   ```bash\n   turbo build\n   ```\n   \n## Running Tests\n\nTo run tests for all packages, use the following command:\n\n```bash\nturbo test\n```\n\n## Linting and Formatting\n\nThis project uses [Biome](https://biomejs.dev/) for linting and formatting. To run lint and format across all packages:\n\n```bash\nturbo lint\n```\n\nTo run lint only on staged files (used by git hooks):\n\n```bash\nturbo lint:staged\n```\n\n## Viewing docs\n\nThe docs use [vitepress](https://vitepress.dev/). To view the docs locally, run:\n\n```bash\npnpm run docs\n```\n\nTo check that docs build correctly and are ready for production:\n\n```bash\npnpm run docs:build\n```\n\n## Project Structure\n\n```\nloglayer/\n├── docs/                         # Documentation (vitepress)\n├── packages/\n│   ├── core/                     # Core packages\n│   │   ├── context-manager/      # Context manager system core\n│   │   ├── log-level-manager/    # Log level manager system core\n│   │   ├── loglayer/             # Main LogLayer implementation\n│   │   ├── plugin/               # Plugin system core\n│   │   ├── transport/            # Transport system core\n│   │   ├── shared/               # Shared utilities and types\n│   │   └── tsconfig/             # Shared TypeScript configurations\n│   ├── context-managers/         # Official context manager implementations\n│   ├── log-level-managers/       # Official log level manager implementations\n│   ├── transports/               # Official transport implementations\n│   ├── mixins/                   # Official mixins implementations\n│   ├── plugins/                  # Official plugins\n│   └── integrations/             # Framework integrations (e.g. ElysiaJS)\n```\n\n## Documentation\n\nFor detailed documentation, visit [https://loglayer.dev](https://loglayer.dev)\n\n## Contributing\n\nWe welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details.\n\nMade with ❤️ by [Theo Gravity](https://suteki.nu) / [Disaresta](https://disaresta.com). Logo by [Akshaya Madhavan](https://www.linkedin.com/in/akshaya-madhavan).\n","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Floglayer%2Floglayer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Floglayer%2Floglayer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Floglayer%2Floglayer/lists"}