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

Feature: Ability to clear log history #1083

Closed
djessup opened this issue Mar 9, 2015 · 145 comments
Closed

Feature: Ability to clear log history #1083

djessup opened this issue Mar 9, 2015 · 145 comments

Comments

@djessup
Copy link

@djessup djessup commented Mar 9, 2015

A feature I've thought would be useful since originally using Fig, and now Compose would be the ability to clear the log history for Composed-managed containers. Long-running or "chatty" containers can end up with a lot of log noise that may not be wanted.

I'd expect a command like the following would solve the problem:
$ docker-compose logs --clear [service]

@dnephin
Copy link
Contributor

@dnephin dnephin commented Mar 13, 2015

I don't think that is a feature supported by the docker daemon. Looking at the api docs, the only option would be to truncate the returned logs to a limited number of lines per container:

https://docs.docker.com/reference/api/docker_remote_api_v1.17/#get-container-logs

@metal3d
Copy link
Contributor

@metal3d metal3d commented Apr 9, 2015

👍 for this issue. I actually use compose to develop a website in Golang, Mongodb and nginx... 5 days after begining I have a long logs that becomes to be worrying. Each time I restart containers append many lines to the log.
@dnephin I don't understand if you give a solution (that I don't understand :)) or if you propose to check if it's possible with api. Sorry for my bad english.

@thaJeztah
Copy link
Member

@thaJeztah thaJeztah commented Apr 9, 2015

Docker 1.6 will add support for logging drivers, see moby/moby#10568 (currently; JSON, syslog and "none") work is in progress for basic log-rotation; moby/moby#11485

@metal3d
Copy link
Contributor

@metal3d metal3d commented Apr 13, 2015

Good to hear that, thanks a lot :)

@djessup
Copy link
Author

@djessup djessup commented Apr 17, 2015

Thanks for the background and update on Docker 1.6 - looking forward to it!

chernjie added a commit to chernjie/elk that referenced this issue Apr 20, 2015
chernjie added a commit to chernjie/elk that referenced this issue Apr 20, 2015
@sgarbesi
Copy link

@sgarbesi sgarbesi commented Jul 16, 2015

docker logs -c (clear) <container> would be great.

+1

@baptistedonaux
Copy link

@baptistedonaux baptistedonaux commented Sep 11, 2015

+1 Really important

@egyptianbman
Copy link

@egyptianbman egyptianbman commented Sep 14, 2015

Holy cow, I just sat through several minutes of logs to get to the end. I'd really appreciate this as well for the sake of not having to rebuild containers constantly.

@jghibiki
Copy link

@jghibiki jghibiki commented Sep 15, 2015

+1

3 similar comments
@vronin
Copy link

@vronin vronin commented Sep 15, 2015

+1

@junajan
Copy link

@junajan junajan commented Sep 17, 2015

+1

@knutole
Copy link

@knutole knutole commented Sep 18, 2015

👍

@Rodeoclash
Copy link

@Rodeoclash Rodeoclash commented Sep 20, 2015

+1

@nafg
Copy link

@nafg nafg commented Sep 21, 2015

+2

@FnTm
Copy link

@FnTm FnTm commented Sep 21, 2015

+1

@dmage
Copy link

@dmage dmage commented Sep 21, 2015

Just for the record, with Docker 1.8 and docker-compose 1.4 there is already exists a method to limit log size using https://docs.docker.com/compose/yml/#log-driver and log-opt max-size:

  log_driver: "json-file"
  log_opt:
    max-size: "100k"
    max-file: "20"
@knutole
Copy link

@knutole knutole commented Sep 21, 2015

@dmage Thanks, exactly what I need.

@OlivierCuyp
Copy link

@OlivierCuyp OlivierCuyp commented Oct 6, 2015

+1000

@sheyman
Copy link

@sheyman sheyman commented Oct 11, 2015

+1 would LOVE this

@joegoggins
Copy link

@joegoggins joegoggins commented Oct 12, 2015

+1

@Rodeoclash
Copy link

@Rodeoclash Rodeoclash commented Oct 12, 2015

@dmage solution works great for us. Those others who are +1ing this, what is wrong with the solution that he's given?

@rosskevin
Copy link

@rosskevin rosskevin commented Oct 12, 2015

@Rodeoclash - I think one use case for this is reuse of a given set of containers for a new run i.e. CI test run. The old logs are irrelevant to the new run, so a clear prior to the next command would clear up confusion.

@SpeCT
Copy link

@SpeCT SpeCT commented Oct 14, 2015

+1

@ballinette
Copy link

@ballinette ballinette commented Oct 19, 2015

+1, same need as @rosskevin

@dnephin
Copy link
Contributor

@dnephin dnephin commented Oct 19, 2015

Ok, to recap:

  • you can do this from a compose file (see #1083 (comment))
  • #265 covers being able to limit the output from the logs command
  • #1756 covers the re-used container case

Going to close this since it's already support or tracked in other issues.

cesine added a commit to cesine/summit-workshop that referenced this issue Jul 26, 2017
removing "-d" so that docker novices can see the errors while debugging
docker/compose#1083 (comment)
cesine added a commit to cesine/summit-workshop that referenced this issue Jul 26, 2017
removing "-d" so that docker novices can see the errors while debugging
docker/compose#1083 (comment)
cesine added a commit to cesine/summit-workshop that referenced this issue Jul 26, 2017
removing "-d" so that docker novices can see the errors while debugging
docker/compose#1083 (comment)
cesine added a commit to cesine/summit-workshop that referenced this issue Jul 26, 2017
removing "-d" so that docker novices can see the errors while debugging
docker/compose#1083 (comment)
cesine added a commit to cesine/summit-workshop that referenced this issue Jul 27, 2017
removing "-d" so that docker novices can see the errors while debugging
docker/compose#1083 (comment)
cesine added a commit to cesine/summit-workshop that referenced this issue Jul 27, 2017
removing "-d" so that docker novices can see the errors while debugging
docker/compose#1083 (comment)
cesine added a commit to cesine/summit-workshop that referenced this issue Jul 27, 2017
removing "-d" so that docker novices can see the errors while debugging
docker/compose#1083 (comment)
@heetap
Copy link

@heetap heetap commented Aug 14, 2017

+1

@sintetico82
Copy link

@sintetico82 sintetico82 commented Dec 15, 2017

+1

3 similar comments
@d13g0s0uz4
Copy link

@d13g0s0uz4 d13g0s0uz4 commented Jan 11, 2018

+1

@ccamacho
Copy link

@ccamacho ccamacho commented Jan 19, 2018

+1

@MPJHorner
Copy link

@MPJHorner MPJHorner commented Jan 22, 2018

+1

@WhiteBearSpirit
Copy link

@WhiteBearSpirit WhiteBearSpirit commented Feb 9, 2018

I made a simple script docker_clear_log.sh:
sudo truncate -s 0 $(docker inspect --format='{{.LogPath}}' $1)
Usage: ./docker_clear_log.sh [Name-or-ID]
Should work if you have sudo rights and log_driver: "json-file" setting for your docker (default).

@gsugambit
Copy link

@gsugambit gsugambit commented Mar 5, 2018

+1

I also tried to temp solution and it appears to work

@educatedwarrior
Copy link

@educatedwarrior educatedwarrior commented Jun 23, 2018

The original issue was never resolved and the issue was closed anyway. Interesting. @djessup , how do you like those apples?

@dhakehurst
Copy link

@dhakehurst dhakehurst commented Jul 11, 2018

would still be nice to have a docker-compose logs --clean

@linvi
Copy link

@linvi linvi commented Oct 12, 2018

Why has this issue been closed without even a comment when the issue in itself has not been solved?

@Ghoughpteighbteau
Copy link

@Ghoughpteighbteau Ghoughpteighbteau commented Oct 30, 2018

@linvi

When I came to this thread, the closing comment had been folded into other comments. It's right here:

#1083 (comment)

I think they're hoping to cover this particular use case through indirect means. Mention you're particular use case and how it's not covered, and it might help the ticket be re-opened. Worst case, someone might point out an easy way to get what you want :D

ewjay pushed a commit to ewjay/fapi-conformance-suite that referenced this issue Oct 30, 2018
'docker-compose restart server' seems to replay all the logs, which on
my mac had reached 125M and it took quite a while to replay that much
data to the terminal.

Found on:

docker/compose#1083 (comment)

and documented here:

https://docs.docker.com/config/containers/logging/json-file/#options
@MartinNiederl
Copy link

@MartinNiederl MartinNiederl commented Aug 29, 2019

Any updates?

@FelixFurtmayr
Copy link

@FelixFurtmayr FelixFurtmayr commented Oct 5, 2019

when there is a log, we should be able to clear it in a simple way.

would be really nice, if you could build the command into it. this seems not hard.
thousands of people would be very happy not having to scroll through everything.

@FelixFurtmayr
Copy link

@FelixFurtmayr FelixFurtmayr commented Oct 6, 2019

If you use docker-compose, use lazydocker for viewing logs. Then there is then no need to delete logs. You get live logs and start with the latest logs. This helps very much with debugging.

grafik

https://github.com/jesseduffield/lazydocker
You can install it with one line and it is a good monitoring tool. It is a pitty that people are not so reasonable to understand that a "delete log" function is a good thing.

But the workaround with lazy docker does it for me. Thank you jesseduffield for giving us the possibility to be lazy with your monitoring tool :-)
Maybe consider donating to lazydocker if this makes debugging/monitoring for you also easier.
And for you docker developers / maintainers: why is the interface from docker not like that?
Docker is pretty awesome, but have a look at lazydocker; there is room for improvement.

@GF-Huang
Copy link

@GF-Huang GF-Huang commented Feb 14, 2020

+2147483647

@kagansari
Copy link

@kagansari kagansari commented Apr 6, 2020

+49324893

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
You can’t perform that action at this time.