# Logging

## Introduction

Laravel Bash writes logs to `storage/logs/laravel.log`, in the same format as Laravel:

```text
[2026-12-04 21:14:03] local.INFO: Created post #9
[2026-12-04 21:14:11] local.ERROR: Job [ProcessPodcast 14] failed with exit code 1
```

## Writing Log Messages

```bash
Log::debug "Checking the cache"
Log::info "Created post #$id"
Log::warning "No event listener is running"
Log::error "Job [$job] timed out"
```

The timestamp comes from `printf '%(%F %T)T'`, which is a Bash builtin, so logging never starts `date`:

```bash
Log::write() {
  local level=$1; shift
  printf '[%(%F %T)T] %s.%s: %s\n' -1 "$APP_ENV" "$level" "$*" >> storage/logs/laravel.log
}
```

## Tailing Log Messages

Laravel Pail tails your logs from the command line. So does `tail`:

```bash
./sail shell
tail -F storage/logs/laravel.log
```

`./artisan dev` already does this, and prefixes each line with `log`.

> [!NOTE]
> Use `tail -F`, not `tail -f`. Lower case follows the open file, so after log rotation it watches a file nobody writes to any more. Upper case follows the name, and reopens it.

## Why not logger?

`logger` sends messages to syslog, which is what system services should do. In a container, there's usually no syslog to send them to.
