[**Documentation**](../../../README)

***

[Documentation](../../../README) / [@zerotal/core](../README) / logger

# logger

Structured, channel-based logging for Zerotal applications.

A single [LogManager](classes/LogManager) owns a set of named [channels](interfaces/LogChannel)
(console, single file, date-rotated `daily` files, `null`, or a `stack` that
fans out to several at once) and routes every [LogEntry](interfaces/LogEntry) to the channel
you select. Entries are enriched automatically with hostname, pid, app/env,
and the active request id, and each channel has its own minimum
[LogLevel](type-aliases/LogLevel). Reach the container-bound manager through the [Log](variables/Log)
facade; configure it with [LoggingConfig](functions/LoggingConfig).

## Examples

```ts
import { Log } from "@zerotal/core/logger";

// Log at any of the five levels on the default channel.
Log.info("User signed in", { userId: 42 });
Log.error("Payment failed", { orderId: 99 }, err);

// Bind shared context, or target a specific channel.
Log.withContext({ requestId: "abc" }).warn("Retrying");
Log.channel("daily").info("Written to today's file");
```

```ts
// config/logging.ts — a "stack" that writes to both console and daily files.
import { LoggingConfig } from "@zerotal/core/logger";

export default LoggingConfig({
  default: "stack",
  channels: {
    stack: { driver: "stack", channels: ["console", "daily"] },
    console: { driver: "console", format: "pretty" },
    daily: { driver: "daily", path: "./storage/logs", days: 14, level: "info" },
  },
});
```

## Channels

- [ConsoleChannel](classes/ConsoleChannel)
- [DailyChannel](classes/DailyChannel)
- [NullChannel](classes/NullChannel)
- [SingleChannel](classes/SingleChannel)
- [StackChannel](classes/StackChannel)
- [LogChannel](interfaces/LogChannel)
- [ChannelConfig](type-aliases/ChannelConfig)

## Configuration

- [LoggingConfig](functions/LoggingConfig)
- [LoggingConfigShape](interfaces/LoggingConfigShape)

## Context

- [BoundLogger](interfaces/BoundLogger)

## Logging

- [Log](variables/Log)
- [LogManager](classes/LogManager)
- [LoggerMiddleware](classes/LoggerMiddleware)
- [LogLevel](type-aliases/LogLevel)
- [LogEntry](interfaces/LogEntry)
- [LogProvider](classes/LogProvider)

## Other

- [LoggerOptions](interfaces/LoggerOptions)
- [TableData](type-aliases/TableData)
- [renderTable](functions/renderTable)
