Use docker logs with remote logging drivers (2024)

Table of contents

You can use the docker logs command to read container logs regardless of theconfigured logging driver or plugin. Docker Engine uses thelocallogging driver to act as cache for reading the latest logs of your containers.This is called dual logging. By default, the cache has log-file rotationenabled, and is limited to a maximum of 5 files of 20 MB each (beforecompression) per container.

Refer to theconfiguration options section to customizethese defaults, or to thedisable dual loggingsection to disable this feature.

Prerequisites

Docker Engine automatically enables dual logging if the configured loggingdriver doesn't support reading logs.

The following examples show the result of running a docker logs command withand without dual logging availability:

Without dual logging capability

When a container is configured with a remote logging driver such as splunk, anddual logging is disabled, an error is displayed when attempting to read containerlogs locally:

With dual logging capability

With the dual logging cache enabled, the docker logs command can be used toread logs, even if the logging driver doesn't support reading logs. The followingexample shows a daemon configuration that uses the splunk remote logging driveras a default, with dual logging caching enabled:

  • Step 1: Configure Docker daemon

    $ cat /etc/docker/daemon.json{ "log-driver": "splunk", "log-opts": { ... (options for "splunk" logging driver) }}
  • Step 2: Start the container

    $ docker run -d busybox --name testlog top
  • Step 3: Read the container logs

    $ docker logs 7d6ac83a89a02019-02-04T19:48:15.423Z [INFO] core: marked as sealed2019-02-04T19:48:15.423Z [INFO] core: pre-seal teardown starting2019-02-04T19:48:15.423Z [INFO] core: stopping cluster listeners2019-02-04T19:48:15.423Z [INFO] core: shutting down forwarding rpc listeners2019-02-04T19:48:15.423Z [INFO] core: forwarding rpc listeners stopped2019-02-04T19:48:15.599Z [INFO] core: rpc listeners successfully shut down2019-02-04T19:48:15.599Z [INFO] core: cluster listeners successfully shut down

Note

For logging drivers that support reading logs, such as the local, json-fileand journald drivers, there is no difference in functionality before or afterthe dual logging capability became available. For these drivers, Logs can beread using docker logs in both scenarios.

Configuration options

The dual logging cache accepts the same configuration options as thelocal logging driver, but with a cache- prefix. These optionscan be specified per container, and defaults for new containers can be set usingthedaemon configuration file.

By default, the cache has log-file rotation enabled, and is limited to a maximumof 5 files of 20MB each (before compression) per container. Use the configurationoptions described below to customize these defaults.

OptionDefaultDescription
cache-disabled"false"Disable local caching. Boolean value passed as a string (true, 1, 0, or false).
cache-max-size"20m"The maximum size of the cache before it is rotated. A positive integer plus a modifier representing the unit of measure (k, m, or g).
cache-max-file"5"The maximum number of cache files that can be present. If rotating the logs creates excess files, the oldest file is removed. A positive integer.
cache-compress"true"Enable or disable compression of rotated log files. Boolean value passed as a string (true, 1, 0, or false).

Use the cache-disabled option to disable the dual logging cache. Disabling thecache can be useful to save storage space in situations where logs are only readthrough a remote logging system, and if there is no need to read logs throughdocker logs for debugging purposes.

Caching can be disabled for individual containers or by default for new containers,when using thedaemon configuration file.

The following example uses the daemon configuration file to use thesplunklogging driver as a default, with caching disabled:

$ cat /etc/docker/daemon.json{ "log-driver": "splunk", "log-opts": { "cache-disabled": "true", ... (options for "splunk" logging driver) }}

Note

For logging drivers that support reading logs, such as the local, json-fileand journald drivers, dual logging isn't used, and disabling the option hasno effect.

Limitations

  • If a container using a logging driver or plugin that sends logs remotelyhas a network issue, no write to the local cache occurs.
  • If a write to logdriver fails for any reason (file system full, writepermissions removed), the cache write fails and is logged in the daemon log.The log entry to the cache isn't retried.
  • Some logs might be lost from the cache in the default configuration because aring buffer is used to prevent blocking the stdio of the container in case ofslow file writes. An admin must repair these while the daemon is shut down.
Use docker logs with remote logging drivers (2024)

References

Top Articles
Lentil Bolognese Recipe
Chicken Tetrazzini (Casserole, Classic Italian Recipe)
Design215 Word Pattern Finder
Restored Republic January 20 2023
<i>1883</i>'s Isabel May Opens Up About the <i>Yellowstone</i> Prequel
State Of Illinois Comptroller Salary Database
Bill Devane Obituary
Regular Clear vs Low Iron Glass for Shower Doors
Craigslist Heavy Equipment Knoxville Tennessee
Fear And Hunger 2 Irrational Obelisk
Grab this ice cream maker while it's discounted in Walmart's sale | Digital Trends
Trac Cbna
Sound Of Freedom Showtimes Near Cinelux Almaden Cafe & Lounge
Dark Chocolate Cherry Vegan Cinnamon Rolls
Equibase | International Results
Joann Ally Employee Portal
Testberichte zu E-Bikes & Fahrrädern von PROPHETE.
Saritaprivate
Sea To Dallas Google Flights
How to Grow and Care for Four O'Clock Plants
The Largest Banks - ​​How to Transfer Money With Only Card Number and CVV (2024)
Accuweather Minneapolis Radar
Essence Healthcare Otc 2023 Catalog
Move Relearner Infinite Fusion
Idle Skilling Ascension
Effingham Daily News Police Report
What Sells at Flea Markets: 20 Profitable Items
Infinite Campus Asd20
Riverstock Apartments Photos
Die wichtigsten E-Nummern
Vip Lounge Odu
A Plus Nails Stewartville Mn
Opsahl Kostel Funeral Home & Crematory Yankton
Everstart Jump Starter Manual Pdf
Cruise Ships Archives
CARLY Thank You Notes
Bimmerpost version for Porsche forum?
Sephora Planet Hollywood
Puffco Peak 3 Red Flashes
Cranston Sewer Tax
Indiana Jones 5 Showtimes Near Cinemark Stroud Mall And Xd
PruittHealth hiring Certified Nursing Assistant - Third Shift in Augusta, GA | LinkedIn
Payrollservers.us Webclock
Free Crossword Puzzles | BestCrosswords.com
Nu Carnival Scenes
FedEx Authorized ShipCenter - Edouard Pack And Ship at Cape Coral, FL - 2301 Del Prado Blvd Ste 690 33990
Colin Donnell Lpsg
Is My Sister Toxic Quiz
Cars & Trucks near Old Forge, PA - craigslist
Diamond Spikes Worth Aj
The Missile Is Eepy Origin
Yoshidakins
Latest Posts
Article information

Author: Jamar Nader

Last Updated:

Views: 6084

Rating: 4.4 / 5 (75 voted)

Reviews: 82% of readers found this page helpful

Author information

Name: Jamar Nader

Birthday: 1995-02-28

Address: Apt. 536 6162 Reichel Greens, Port Zackaryside, CT 22682-9804

Phone: +9958384818317

Job: IT Representative

Hobby: Scrapbooking, Hiking, Hunting, Kite flying, Blacksmithing, Video gaming, Foraging

Introduction: My name is Jamar Nader, I am a fine, shiny, colorful, bright, nice, perfect, curious person who loves writing and wants to share my knowledge and understanding with you.