---
# System prepended metadata

title: Spin log dir

---

# Spin log dir

## Sources

| Source     | Default  |
| ---------  | -------- |
| Spin       | console  |
| Trigger    | console  |
| User code  | console  |

## Log dir

`--log-dir` defines the location to put the log files in.
Logs are split in to files based on sources per directory, and one files for each time a new Spin instance is started.
Given `--log-dir` is `/logs/``
- Spin logs go to `/logs/spin/[datw/time]-spin.log`, where date/time is the time the Spin process was started.
- Trigger logs go to `/logs/component-[id]/[date/time]-[trigger-type-name].log`, where date/time is the time the Spin process for the trigger was started.
- User code logs go to `/logs/component-[id]/[date/time]-[component-id].log`, where date/time is the time the Spin process for the component was started.
This can potentially have a default, and be allowed to be omitted.

## Scenarios

### 1 - All sources to console

Default behaviour

`spin up`

### 2 - All sources to files only
`spin up --log-to-file All --log-to-stdout None`
Indicates that all sources will log to file(s), and none will log to stdout. Implies a default log dir.

Potential short-name `-fo` for files only or '`-hush` or `-sh`'

With specific log dir `spin up --log-to-file All --log-dir ~/.log/spin --log-to-stdout None`

### 3 - Selective sources to console and files

Can only choose sources, not individual components.

The following will store all output from user code to files. Implies a default log dir.

`spin up --log-to-file Spin,Triggers --log-to-stdout Components`

The following will store all output from triggers to files, and from triggers, Spin and user code to stdout:

`spin up --log-to-file Triggers`

The following will store all output from to files, and only from user code to stdout:

`spin up --log-to-file All --log-to-stdout Components`

### 4 - Everything Everywhere All at Once (I recommend the movie)

Given an implicit `--log-dir` and stdout for all sources is default.

`spin up --log-to-file All`