LoggerModule
The main NestJS module for @shinijs/logger.
Import
typescript
import { LoggerModule } from '@shinijs/logger';Usage
typescript
import { Module } from '@nestjs/common';
import { LoggerModule } from '@shinijs/logger';
@Module({
imports: [LoggerModule],
})
export class AppModule {}Description
LoggerModule is a global NestJS module that provides logging functionality throughout your application. It:
- Registers
CustomLoggeras a global provider - Registers
LoggerFactoryfor creating context-bound loggers - Integrates with
@nestjs/configfor configuration - Provides the
ILoggertoken for dependency injection
Global Module
The module is marked as @Global(), which means:
- You only need to import it once in your root
AppModule - All providers are available throughout your application without re-importing
- No need to add it to feature modules
Exports
The module exports:
CustomLogger- Main logger serviceLoggerFactory- Factory for context-bound loggersILogger- Logger interface token
Configuration
The module automatically integrates with @nestjs/config. Configuration is read from:
- Environment variables (see Configuration Guide)
- NestJS
ConfigModule(if configured)
Example
typescript
import { Module } from '@nestjs/common';
import { ConfigModule } from '@nestjs/config';
import { LoggerModule } from '@shinijs/logger';
@Module({
imports: [
ConfigModule.forRoot({
isGlobal: true,
}),
LoggerModule,
],
})
export class AppModule {}See Also
- CustomLogger - Main logger service
- LoggerFactory - Factory for context-bound loggers
- Configuration Guide - Configuration options