Over a million developers have joined DZone.

Simple Logging to Logentries from a Docker Container

· DevOps Zone

The DevOps zone is brought to you in partnership with Sonatype Nexus. The Nexus suite helps scale your DevOps delivery with continuous component intelligence integrated into development tools, including Eclipse, IntelliJ, Jenkins, Bamboo, SonarQube and more. Schedule a demo today

Guest blog post on quick tips for logging from a Docker container by Logentries customer Gal Ben-Haim, Head of Software at Augury, @gbenhaim

While building Docker images for a production deployment I encountered a problem with proper logging of what’s going on inside the containers, especially if using supervisord to run multiple processes. Logging with Docker

One simple solution can be to share the /var/log/supervisor directory with the host.

Since I’m already using Logentries for centralized logging solution and I’ve already written a Golang client lib for it, I decided to use it for a simple log dump solution that can be used from inside a Docker container — https://github.com/bsphere/lecat

All there is left to do is create a new Logentries token and change the stdout change the random log file names of supervisord child processes to known path as described in http://supervisord.org/configuration.html.

Then, add additional supervisord child processes such as:

command=tail -F /var/log/nginx/access.log | lecat -token <logentries_token>

The DevOps zone is brought to you in partnership with Sonatype Nexus. Use the Nexus Suite to automate your software supply chain and ensure you're using the highest quality open source components at every step of the development lifecycle. Get Nexus today


Published at DZone with permission of Trevor Parsons, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}