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?

docker

How to start HAProxy with Docker on Raspberry

Raspberry is very cheap and has quite a lot of applications, for example, some people use it as a Wi-Fi router, For game consoles, monitors and many other IoT-related applications, I use it as a HAProxy. Long story short, since I have an old Windows server running old versions of PHP and Apache, and can't set up HTTPS certificates, I wanted to say Help through HAProxy. Let this old server also have https URL, So to share my docker-compose.yml configuration.

docker,laravel

It's super easy to build a Lravel development environment with Docker

Are you ready for the Laravel 5.5 system environment? laravel/framework 5.5.x-dev requires php >=7.0 -> your PHP version (5.6.30) does not satisfy that requirement. This article describes how to create a Laravel development environment using Docker. With the simple to explosive D-Laravel simple bash, Don't say that I can't set up a Laravel development environment.