Logger service for writing log messages to configured handlers

Loggers are created from a LoggerFactory with a specific scope/category. All log messages written to a logger will be sent to all handlers configured in the factory.

Example

const logger = loggerFactory.createLogger('my-component');

logger.info('Component initialized');
logger.debug('Processing data', { itemCount: 42 });
logger.warn('Deprecated API usage detected');
logger.error('Failed to fetch data', error, { url: '/api/data' });

Hierarchy

  • Logger

Properties

Methods

Properties

scope: string

The scope/category for this logger instance

Methods

  • Logs a debug message

    Use for detailed diagnostic information useful during development and troubleshooting. Debug logs are typically disabled in production and should include technical details like internal state, intermediate values, or execution flow.

    Example

    logger.debug('Cache miss, fetching from API', { key: 'user:123' });
    logger.debug('Rendering component', { props: componentProps });

    Parameters

    • message: string

      The log message

    • Optional data: LogData

      Optional additional data to include with the log entry

    Returns void

  • Logs an error message

    Use for failures and exceptions that prevent normal operation or indicate something has gone wrong. Error logs should always describe what failed and include relevant context to aid in diagnosis.

    Example

    logger.error('Failed to fetch user data', error, { userId: 123 });
    logger.error('Invalid configuration detected', undefined, { config: invalidConfig });

    Parameters

    • message: string

      The log message

    • Optional error: Error

      Optional error object

    • Optional data: LogData

      Optional additional data to include with the log entry

    Returns void

  • Logs an informational message

    Use for significant application events that represent normal behavior. Info logs should capture key milestones, successful operations, or state transitions that are useful for understanding application flow in production.

    Example

    logger.info('User authenticated', { userId: user.id });
    logger.info('File uploaded successfully', { filename: 'report.pdf', size: 2048 });

    Parameters

    • message: string

      The log message

    • Optional data: LogData

      Optional additional data to include with the log entry

    Returns void

  • Logs a warning message

    Use for unexpected situations that don't prevent the application from functioning but may indicate potential issues, deprecated usage, or suboptimal conditions. Warnings should be actionable and suggest something that may need attention.

    Example

    logger.warn('API response time exceeded threshold', { duration: 3500, threshold: 3000 });
    logger.warn('Using deprecated configuration option', { option: 'legacy_mode' });

    Parameters

    • message: string

      The log message

    • Optional data: LogData

      Optional additional data to include with the log entry

    Returns void