Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable log rotating #28

Open
erkyrath opened this issue Jan 25, 2022 · 4 comments
Open

Enable log rotating #28

erkyrath opened this issue Jan 25, 2022 · 4 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@erkyrath
Copy link
Member

I see that when you do docker-compose up --build, log info goes to stdout. This should go to /var/log/unbox/unbox.log.

Then we'd have to set up logrotate. Except I don't know exactly how to do that. For Apache, logrotate is configured to do "/etc/init.d/apache2 reload" after rotation so that the server closes and reopens its logging file handle. What is the equivalent here?

@curiousdannii
Copy link
Member

curiousdannii commented Jan 25, 2022

Docker has various logging options: https://docs.docker.com/config/containers/logging/

But I did see that the default is some JSON system, and it doesn't support any log rotating. So yes, this is important. I know nothing about it though.

FYI, the command to start it in the background is docker-compose up --build -d.

@curiousdannii curiousdannii changed the title Logging Enable log rotating Jan 25, 2022
@curiousdannii curiousdannii added enhancement New feature or request help wanted Extra attention is needed labels Jan 25, 2022
@erkyrath
Copy link
Member Author

The suggested plan seems to be "log-driver": "local" , which shoves the logs into an opaque file with automatic rotation. Then you use the docker logs command to examine them.

docker info indicates that the current log-driver is the (default) "json-file", and docker logs does in fact work. But I have no idea where those json files are. Inside each container, I suppose.

@erkyrath
Copy link
Member Author

erkyrath commented Feb 1, 2022

The logs now use log-driver:local, but we observe that bringing the containers down and back up wipes the logs. This is not ideal.

Digging around, I found the comment:

You can persist all container log files by creating a volume mount point to the Docker host machine or central log server.

This is still on the todo list.

@erkyrath
Copy link
Member Author

erkyrath commented Feb 7, 2022

I looked further into this and it's not as obvious as the comment above implies.

The current logs are not kept inside the container. They're in a container-specific folder on the host. (/var/lib/docker/containers/$ID/local-logs) So that's why they disappear when the container goes down. I did not find a way to change this.

There's a lot of blog discussion about centralizing your log files but they seem to boil down to three plans:

  • Have your app write logs to a location inside the container (rather than printing to stdout and letting docker capture that).
  • Use a different log driver such as journald. Then set that up on the host.
  • Use my awesome log-capturing product (written by the author of this blog post).

None of these sounds simple, unless you know more about journald than me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants