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, 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?

d-laravel, docker, laravel, docker-compose

D-Laravel v1.0.0 release change description

In order to allow the container to be used more flexibly, D-Laravel has released version v1.0.0, which is not backward compatible. https://github.com/DevinY/dlaravel/releases/tag/v1.0.0 If you are using before v1.0.0, you need to modify the .env file of the Laravel project, change DB_HOST=127.0.0.1 to DB_HOST=db If you have a custom docker-compose-custom.yml file....more

docker,dlaravel

D-Laravel 1.5.5 Change Notes

D-Laravel's fpm image was rebuilt using the official dockerfile of docker php before php 7.2.1. And so I can specify that the default owner of fpm is dlaravel, --with-fpm-user=USER Set the user for php-fpm to run as. (default: nobody) --with-fpm-group=GRP Set the group for php-fpm to run as.