Skip to content

Docker:Logging

Docker Logging 방법.

Drivers

Local File logging driver

docker run -it --log-driver local --log-opt max-size=10m --log-opt max-file=3 alpine ash

Options:

Option</code>

Description

<code>Example value

max-size

The maximum size of the log before it is rolled. A positive integer plus a modifier representing the unit of measure (k, m, or g). Defaults to 20m.

--log-opt max-size=10m

max-file

The maximum number of log files that can be present. If rolling the logs creates excess files, the oldest file is removed. A positive integer. Defaults to 5.

--log-opt max-file=3

compress

Toggle compression of rotated log files. Enabled by default.

--log-opt compress=false

Graylog Extended Format logging driver

GraylogGEFL 포맷으로 출력하는 방법:

docker run --log-driver gelf --log-opt gelf-address=udp://localhost:12201 --rm -it ubuntu bash -c 'while true; do echo kkkkk; sleep 1; done'

자세한 내용은 Logstash#Docker GELF logging 항목 참조.

참고로 gelf는 Graylog Extended Log Format의 약자이다.

See also