---
description: Learn how to use the json-file logging driver with Docker Engine
keywords: json-file, docker, logging, driver
title: JSON File logging driver
aliases:
- /engine/reference/logging/json-file/
- /engine/admin/logging/json-file/
- /config/containers/logging/json-file/
---
By default, Docker captures the standard output (and standard error) of all your containers,
and writes them in files using the JSON format. The JSON format annotates each line with its
origin (`stdout` or `stderr`) and its timestamp. Each log file contains information about
only one container.
```json
{
"log": "Log line is here\n",
"stream": "stdout",
"time": "2019-01-01T11:11:11.111111111Z"
}
```
> [!WARNING]
>
> The `json-file` logging driver uses file-based storage. These files are designed
> to be exclusively accessed by the Docker daemon. Interacting with these files
> with external tools may interfere with Docker's logging system and result in
> unexpected behavior, and should be avoided.
## Usage
To use the `json-file` driver as the default logging driver, set the `log-driver`
and `log-opts` keys to appropriate values in the `daemon.json` file, which is
located in `/etc/docker/` on Linux hosts or
`C:\ProgramData\docker\config\` on Windows Server. If the file does not exist, create it first. For more information about
configuring Docker using `daemon.json`, see
[daemon.json](/reference/cli/dockerd.md#daemon-configuration-file).
The following example sets the log driver to `json-file` and sets the `max-size`
and `max-file` options to enable automatic log-rotation.
```json
{
"log-driver": "json-file",
"log-opts": {
"max-size": "10m",
"max-file": "3"
}
}
```
> [!NOTE]
>
> `log-opts` configuration options in the `daemon.json` configuration file must
> be provided as strings. Boolean and numeric values (such as the value for
> `max-file` in the example above) must therefore be enclosed in quotes (`"`).
Restart Docker for the changes to take effect for newly created containers.
Existing containers don't use the new logging configuration automatically.
You can set the logging driver for a specific container by using the
`--log-driver` flag to `docker container create` or `docker run`:
```console
$ docker run \
--log-driver json-file --log-opt max-size=10m \
alpine echo hello world
```
### Options
The `json-file` logging driver supports the following logging options:
| Option | Description | Example value |