Logger namespace with Effect-based logging functions and a synchronous logger for non-Effect code.
Usage
Effect Logging
UseLogger.info, Logger.debug, Logger.warn, and Logger.error in Effect code:
Log with Attributes
Pass an object as the first argument to add structured attributes:Log without Attributes
Pass only a message string:Synchronous Logger
For logging outside of Effect code (e.g., in callbacks or external libraries), useLogger.sync():
With Initial Annotations
Create a logger with persistent annotations:Child Loggers
Create child loggers with additional annotations:Per-Call Attributes
Add attributes to individual log calls:API Reference
Effect Logging Functions
Synchronous Logger
Complete Example
Integration with createFetchHandler
createFetchHandler automatically logs:
- Request start: Pathname and request ID
- Request end: Status code (info for 2xx/3xx, warn for others)
- Errors: Unhandled exceptions with full cause
requestId annotation.
Example output: