Skip to content

Logger Implementations

DomusJS provides a pluggable Logger system that lets you integrate different logging backends while keeping your application code clean and consistent.

✅ All modules and services rely on the Logger interface, not on specific libraries.
✅ You can swap implementations without changing your business logic.


DomusJS ships with several ready-to-use logger integrations:

Simple wrapper over console.*:

ConsoleLogger

✅ Great for development and local testing.


Integration with Pino, a fast, structured logger:

PinoLogger

✅ Suitable for production setups where performance matters.


Integration with OpenTelemetry, sending logs to observability backends like Signoz, Datadog, etc.

OpenTelemetryLogger

✅ Ideal for teams that want full tracing, metrics, and logging integration.


Use the registerDomusCore() helper:

import { registerDomusCore, PinoLogger } from '@domusjs/infrastructure';
registerDomusCore({
// Alternatively, you can use the ConsoleLogger, OpenTelemetryLogger or your own logger implementation
logger: new PinoLogger()
});

✅ Once registered, the logger is injectable anywhere:

import { Logger } from '@domusjs/core';
import { inject, injectable } from 'tsyringe';
@injectable()
export class SomeService {
constructor(@inject('Logger') private readonly logger: Logger) {}
doSomething() {
this.logger.info('Service action executed', { context: 'SomeService' });
}
}

✅ Always use the Logger interface — avoid calling raw console.* directly.
✅ Use structured attributes for context ({ context: 'SomeService' }).
✅ Integrate the logger with your tracing setup for unified observability.
✅ Centralize configuration and never instantiate loggers manually in services.