Child Loggers
Create namespaced loggers for different parts of your application.
Overview
Child loggers help you:
- Organize logs — Group logs by component or feature
- Filter logs — Find logs from specific parts of your app
- Inherit configuration — Share settings with parent logger
Creating Child Loggers
typescript
Namespace Hierarchy
Child loggers can be nested to create hierarchies:
typescript
Overriding Configuration
Child loggers can have their own settings:
typescript
Override Context
typescript
Use Cases
By Feature
typescript
By Layer
typescript
By Component (React)
typescript
Pattern: Service Logger
Common pattern for creating a logger per service:
typescript
typescript
Filtering by Namespace
Use namespace patterns in your log aggregation:
bash
Or configure transports to filter:
typescript
Namespace in Sampling
Use namespace sampling for fine-grained control:
typescript