by Devin Yang
(This article was automatically translated.)

Published - 6 years ago ( Updated - 6 years ago )

Docker has a lot of built-in log mechanisms to help us obtain service information executed in the container.
These mechanisms (mechanisms) we usually call logging drivers.

If you want to change the default logging drivers (logging drivers), you can set the name of the login-driver program in the daemon.json file. This file is usually placed in the /etc/docker directory of the linux system, or C:\ProgramData\docker\config\ on Windows
The default logging driver of Docker is json-file, change it to syslog.

On MacOS system, it can be set by Docker preferences:
After restarting, you will find that the log records have changed to syslog.

For more configuration settings of Docker Deamon, you can refer to the official link:

Use the command to query the default Logging Driver.
docker info |grep Logging

Below is a list of supported Loggin drivers:
driver Description
none No logs will be available for the container and docker logs will not return any output.
json-file The logs are formatted as JSON. The default logging driver for Docker.
syslog Writes logging messages to the syslog facility. The syslog daemon must be running on the host machine.
journald Writes log messages to journald . The journald daemon must be running on the host machine.
gelf Writes log messages to a Graylog Extended Log Format (GELF) endpoint such as Graylog or Logstash.
fluentd Writes log messages to fluentd (forward input). The fluentd daemon must be running on the host machine.
awslogs Writes log messages to Amazon CloudWatch Logs.
splunk Writes log messages to splunk using the HTTP Event Collector.
etwlogs Writes log messages as Event Tracing for Windows (ETW) events. Only available on Windows platforms.
gcplogs Writes log messages to Google Cloud Platform (GCP) Logging.
logentries Writes log messages to Rapid7 Logentries.

When I create a container with the docker run command,
Or when docker-compose starts, specify the logging driver to use.
For example, the dokcer on my Synolog Nas, Mo Ming ran a strange logging driver called db. (The following figure)

I want to execute json-file when my docker-compose starts.
you can make up
driver: json-file


Tags: docker

Devin Yang

Feel free to ask me, if you don't get it.:)

No Comment

Post your comment

Login is required to leave comments

Similar Stories


D-Laravel learning three stages

Chat about the three stages of using D-Laravel, why use D-Laravel. Because the configuration files used by D-Laravel are quite simple, it is very suitable for beginners of Docker to learn, And users who do not know how to use Docker can also use the two commands ./console and ./create to create a project.


Storage and retrieval of Docker image

How to archive the docker image into a tar file and load back the docker image. We can use docker save and docker load.

wordpress, d-laravel, docker, docker-compose

How to install Wordpress with D-Laravel

An 8-minute teaching video, introducing the installation of Wordpress on D-Laravel. D-Laravel is a docker-compose Laravel framework development environment, but it does not mean that it cannot be used to install other things. This video introduces the use of D-Laravel to install non-Laravel PHP projects, You can learn the usage of related instructions on D-Laravel: ./create --host usage, docker-compose up -d and ./console mysql usage, The database connection setting method after D-Laravel v1.0.0.