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

***

[Documentation](../../../README) / [zerotal](../../README) / [logger](../README) / DailyChannel

# Class: DailyChannel

Defined in: [packages/core/src/logger/channels/DailyChannel.ts:26](https://github.com/zerotaldev/zerotal/blob/1d6fb26b05b18ba077de1bfaeb46c42131cd8b70/packages/core/src/logger/channels/DailyChannel.ts#L26)

Appends entries as JSON lines to a date-rotated file, one file per day named
`YYYY-MM-DD.log` (derived from the entry's timestamp) inside a directory.

Writes go through a [StorageDriver](../../storage/interfaces/StorageDriver), so the log trail uses the same file
API as uploads and the media library rather than a second, private way of
putting bytes on disk — and inherits its path-traversal guard for free.

When a retention window (`days`) is given, files whose modification time is
older than the cutoff are pruned — checked at most once every 24 hours, in
the background, and only on write. The directory is created on demand.

## Example

```ts
// config/logging.ts — keep 14 days of daily files under ./storage/logs
file: { path: "./storage/logs", days: 14 },
```

## Implements

- [`LogChannel`](../interfaces/LogChannel)

## Constructors

### Constructor

> **new DailyChannel**(`_dir`, `_days?`, `disk?`): `DailyChannel`

Defined in: [packages/core/src/logger/channels/DailyChannel.ts:37](https://github.com/zerotaldev/zerotal/blob/1d6fb26b05b18ba077de1bfaeb46c42131cd8b70/packages/core/src/logger/channels/DailyChannel.ts#L37)

#### Parameters

##### \_dir

`string`

Directory that holds the per-day log files.

##### \_days?

`number`

Retention window in days; older files are pruned. Omit to keep files forever.

##### disk?

[`StorageDriver`](../../storage/interfaces/StorageDriver)

Driver to write through. Defaults to a [LocalDriver](../../storage/classes/LocalDriver) rooted at `_dir`.
  Pass one to send the trail somewhere else — it must support `append`, which
  rules out object stores.

#### Returns

`DailyChannel`

## Methods

### write()

> **write**(`entry`): `Promise`\<`void`\>

Defined in: [packages/core/src/logger/channels/DailyChannel.ts:45](https://github.com/zerotaldev/zerotal/blob/1d6fb26b05b18ba077de1bfaeb46c42131cd8b70/packages/core/src/logger/channels/DailyChannel.ts#L45)

#### Parameters

##### entry

[`LogEntry`](../interfaces/LogEntry)

#### Returns

`Promise`\<`void`\>

#### Implementation of

[`LogChannel`](../interfaces/LogChannel).[`write`](../interfaces/LogChannel#write)
