LogLayer is a unified logger that routes logs to various logging libraries and cloud providers while providing a fluent API for specifying log messages, metadata and errors, enhancing and standardizing the developer experience around writing logs.
- Structured Logging: Write logs with a fluid API that makes adding tags, metadata and errors simple.
- Bring Your Own Logger: Use console logging when starting out, then switch to another logging provider later without changing your application code.
- Extensible Plugin System: Transform, enrich, and filter logs with plugins that lets you customize every aspect of your logging pipeline.
- Multi-logger Support: Fan out logs to multiple logging libraries and cloud providers such as DataDog and New Relic at the same time.
Challenges with logging—choosing, using, and maintaining the right logger for various projects—are a common experience. While most loggers offer the usual methods like info, warn, and error, they vary significantly in handling structured metadata or Error objects. This can lead to ad-hoc solutions, like serializing errors or writing custom pipelines, just to get logs formatted correctly.
LogLayer was built to address these pain points by introducing a fluid, expressive API. With methods like withMetadata and withError, LogLayer separates object injection from the log message itself, making logging code both cleaner and more maintainable.
Logs are processed through a LogLayer Transport, which acts as an adapter for the preferred logging library. This design offers several key advantages:
- Multi-Transport Support: Send logs to multiple destinations (e.g., DataDog and New Relic) simultaneously. This feature can be used to ship logs directly to DataDog without relying on their APM package or sidecars.
- Easy Logger Swapping: If Pino has been used with Next.js, issues might arise where it doesn’t work out of the box after a production build without webpack hacks. With LogLayer, a better-suited library can be swapped in without touching the logging code.