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:
daemon.json
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:
https://docs.docker.com/engine/reference/commandline/dockerd/#daemon-configuration-file

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
loggin:
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


docker,sqlserver

D-Laravel builds SQL Server environment

How to build D-Laravel's SQL Server environment

docker

Devin Yang's Notes for Beginners with Docker

These are my notes when I first learned Docker. It is a bit rough and I have adjusted it a bit. But I think for Docker beginners, it should be able to provide some preliminary concepts, Welcome to refer to it.

docker, tinkerwell, tinker, laravel

Application of Tinkerwell and docker environment

In fact, I don't use Tinkerwell recently because it keeps costing me money to update. If you want to test the direct ssh host, it’s done, isn’t it?