Introduction: Docker is a qualified Java development engineer must master the knowledge, fox will write down their own understanding, this article only represents my summary and understanding, if there are mistakes, welcome to correct…

$docker logs [OPTIONS] CONTAINER OPTIONS -- Details displays more information -f, --follow traces real-time logs --since string displays logs since a timestamp, or relative time, such as 42m (42 minutes) --tail String Displays how many lines of the log from the end, The default is all-t, --timestamps displays timestamps --until string displays logs from before a timestamp, or relative time, such as 42m (42 minutes) example: to view logs after a specified time, only the last 100 lines are displayed: $docker logs -f -t --since="2018-02-08" --tail=100 CONTAINER_ID $docker logs --since 30m CONTAINER_ID Specifies whether to log in a specific time range. $docker logs -t --since=" 2018-02-08t13:23:37 "CONTAINER_ID specifies whether to log in a specific time range.  $ docker logs -t --since="2018-02-08T13:23:37" --until "2018-02-09T12:23:37" CONTAINER_ID 1. $docker-compose logs $docker-compose logs $docker-compose logs The real-time log display effect is the same as tail-f filename in Linux. The latest content can be refreshed and displayed on the screen. $ docker logs -f <CONTAINER> 3. The tail effect is the same as Linux tail-n20filename, showing the last 20 lines. $ docker logs --tail 20 <CONTAINER> 4. Using grep to filter the log log for example find all contain "error" : $docker logs | grep error 5. For example, if you want to view logs from a certain point in time, use the --since option to display logs from a specified point in time to the most recent: $docker logs --since 2018-09-25T12:01:46.452616z <CONTAINER> $docker logs --since 2018-09-25T12:01:48.551341z --until 2018-09-25T12:01:48.561714z <CONTAINER> 6. These options can all be used together, for example:  $ docker logs --tail 10 <CONTAINER> | grep info $ docker logs -f --since xxx --tail=10 <CONTAINER> 7. Write all error logs to the specified file: $docker logs - t < CONTAINER > | grep error > > logs_error. TXT can write a script to write the content of interest to the file, can also import our logging system further, convenient viewing. Docker logs -f suning --tail 100 -f: continuously view the log output in real time --tail: the number of lines displayed from the end of the log. Docker logs -t suning | grep "start" grep returns the string contains the line For example, you should be displayed in the log time, use the -t such as: Docker logs -T --since 2020-12-03T2:54:42.093534805z --until 2020-12-03T2:54:42.095684382z Suning --since start timestamp --until end timestampCopy the code

Conclusion: Ever is to learn to read people’s blog technology, some of them have essence blog also have to play around the CV of solution, so the decided to study the knowledge sharing for everyone, mainly want to go to the sea after less detours, more positive energy blog, if there are any errors, welcome to point out mistakes, only hope that we can learn knowledge in my blog, Solve the problem, then it is enough. Thank you! (Please note the original source for reprint)