NAME¶ 名称
podman-logs - Display the logs of one or more containers
podman-logs - 显示一个或多个容器的日志
SYNOPSIS¶ 概要
podman logs [options] container [container…]
podman logs [选项] 容器 [容器...]
podman container logs [options] container [container…]
podman 容器日志 [选项] 容器 [容器...]
DESCRIPTION¶ 描述
The podman logs command batch-retrieves whatever logs are present for one or more containers at the time of execution.
This does not guarantee execution order when combined with podman run (i.e. the run may not have generated
any logs at the time podman logs was executed).
podman logs 命令在执行时批量检索一个或多个容器当前存在的所有日志。当与 podman run 结合使用时,这并不保证执行顺序(即在执行 podman logs 时,run 可能尚未生成任何日志)。
OPTIONS¶ 选项
--color¶
Output the containers with different colors in the log.
在日志中使用不同颜色输出容器。
--follow, -f¶
Follow log output. Default is false.
跟踪日志输出。默认值为 false。
Note: When following a container which is removed by podman container rm
or removed on exit (podman run --rm ...
), there is a chance that the log
file is removed before podman logs
reads the final content.
注意: 当跟踪一个由 podman container rm
删除或在退出时删除的容器( podman run --rm ...
)时,有可能日志文件在 podman logs
读取最终内容之前被删除。
--latest, -l¶
Instead of providing the container name or ID, use the last created container.
Note: the last started container can be from other users of Podman on the host machine.
(This option is not available with the remote Podman client, including Mac and Windows
(excluding WSL2) machines)
不要提供容器名称或 ID,而是使用最后创建的容器。注意:最后启动的容器可能来自主机上其他 Podman 用户。(此选项在远程 Podman 客户端中不可用,包括 Mac 和 Windows(不包括 WSL2)主机)
--names, -n¶ --名称, -n ¶
Output the container names instead of the container IDs in the log.
在日志中输出容器名称而不是容器 ID。
--since=TIMESTAMP¶ --自指定时间戳开始=时间戳 ¶
Show logs since TIMESTAMP. The --since option can be Unix timestamps, date formatted timestamps, or Go duration
strings (e.g. 10m, 1h30m) computed relative to the client machine’s time. Supported formats for date formatted
time stamps include RFC3339Nano, RFC3339, 2006-01-02T15:04:05, 2006-01-02T15:04:05.999999999, 2006-01-02Z07:00,
and 2006-01-02.
从时间戳开始显示日志。--since 选项可以是 Unix 时间戳、日期格式化的时间戳,或相对于客户端机器时间计算的 Go 时长字符串(例如 10m、1h30m)。支持的日期格式化时间戳格式包括 RFC3339Nano、RFC3339、2006-01-02T15:04:05、2006-01-02T15:04:05.999999999、2006-01-02Z07:00 和 2006-01-02。
--tail=LINES¶
Output the specified number of LINES at the end of the logs. LINES must be an integer. Defaults to -1,
which prints all lines
在日志末尾输出指定数量的行数。LINES 必须是整数。默认为 -1,表示打印所有行。
--timestamps, -t¶ --时间戳, -t ¶
Show timestamps in the log outputs. The default is false
在日志输出中显示时间戳。默认值为 false
--until=TIMESTAMP¶ --直到=时间戳 ¶
Show logs until TIMESTAMP. The --until option can be Unix timestamps, date formatted timestamps, or Go duration
strings (e.g. 10m, 1h30m) computed relative to the client machine’s time. Supported formats for date formatted
time stamps include RFC3339Nano, RFC3339, 2006-01-02T15:04:05, 2006-01-02T15:04:05.999999999, 2006-01-02Z07:00,
and 2006-01-02.
显示日志直到时间戳。--until 选项可以是 Unix 时间戳、日期格式化的时间戳,或相对于客户端机器时间计算的 Go 时长字符串(例如 10m、1h30m)。支持的日期格式化时间戳格式包括 RFC3339Nano、RFC3339、2006-01-02T15:04:05、2006-01-02T15:04:05.999999999、2006-01-02Z07:00 和 2006-01-02。
EXAMPLE¶ 例子 ¶
To view a container’s logs:
查看容器的日志:
podman logs -t b3f2436bdb978c1d33b1387afb5d7ba7e3243ed2ce908db431ac0069da86cb45
2017/08/07 10:16:21 Seeked /var/log/crio/pods/eb296bd56fab164d4d3cc46e5776b54414af3bf543d138746b25832c816b933b/c49f49788da14f776b7aa93fb97a2a71f9912f4e5a3e30397fca7dfe0ee0367b.log - &{Offset:0 Whence:0}
1:C 07 Aug 14:10:09.055 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
1:C 07 Aug 14:10:09.055 # Redis version=4.0.1, bits=64, commit=00000000, modified=0, pid=1, just started
1:C 07 Aug 14:10:09.055 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
1:M 07 Aug 14:10:09.055 # You requested maxclients of 10000 requiring at least 10032 max file descriptors.
1:M 07 Aug 14:10:09.055 # Server can't set maximum open files to 10032 because of OS error: Operation not permitted.
1:M 07 Aug 14:10:09.055 # Current maximum open files is 4096. maxclients has been reduced to 4064 to compensate for low ulimit. If you need higher maxclients increase 'ulimit -n'.
1:M 07 Aug 14:10:09.056 * Running mode=standalone, port=6379.
1:M 07 Aug 14:10:09.056 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
1:M 07 Aug 14:10:09.056 # Server initialized
To view only the last two lines in container’s log:
仅查看容器日志中的最后两行:
podman logs --tail 2 b3f2436bdb97
# WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
# Server initialized
To view all containers logs:
查看所有容器日志:
podman logs -t --since 0 myserver
1:M 07 Aug 14:10:09.055 # Server can't set maximum open files to 10032 because of OS error: Operation not permitted.
1:M 07 Aug 14:10:09.055 # Current maximum open files is 4096. maxclients has been reduced to 4064 to compensate for low ulimit. If you need higher maxclients increase 'ulimit -n'.
1:M 07 Aug 14:10:09.056 * Running mode=standalone, port=6379.
1:M 07 Aug 14:10:09.056 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
1:M 07 Aug 14:10:09.056 # Server initialized
To view a container’s logs since a certain time:
查看自特定时间以来容器的日志:
podman logs -t --since 2017-08-07T10:10:09.055837383-04:00 myserver
1:M 07 Aug 14:10:09.055 # Server can't set maximum open files to 10032 because of OS error: Operation not permitted.
1:M 07 Aug 14:10:09.055 # Current maximum open files is 4096. maxclients has been reduced to 4064 to compensate for low ulimit. If you need higher maxclients increase 'ulimit -n'.
1:M 07 Aug 14:10:09.056 * Running mode=standalone, port=6379.
1:M 07 Aug 14:10:09.056 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
1:M 07 Aug 14:10:09.056 # Server initialized
To view a container’s logs generated in the last 10 minutes:
查看最近 10 分钟内生成的容器日志:
podman logs --since 10m myserver
# Server can't set maximum open files to 10032 because of OS error: Operation not permitted.
# Current maximum open files is 4096. maxclients has been reduced to 4064 to compensate for low ulimit, Increase 'ulimit -n' when higher maxclients are required.
To view a container’s logs until 30 minutes ago:
查看容器日志直到 30 分钟前:
podman logs --until 30m myserver
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 10.0.2.100. Set the 'ServerName' directive globally to suppress this message
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 10.0.2.100. Set the 'ServerName' directive globally to suppress this message
[Tue Jul 20 13:18:14.223727 2021] [mpm_event:notice] [pid 1:tid 140021067187328] AH00489: Apache/2.4.48 (Unix) configured -- resuming normal operations
[Tue Jul 20 13:18:14.223819 2021] [core:notice] [pid 1:tid 140021067187328] AH00094: Command line: 'httpd -D FOREGROUND'
SEE ALSO¶ 参见 ¶
HISTORY¶ 历史 ¶
February 2018, Updated by Brent Baude bbaude@redhat.com
2018 年 2 月,由 Brent Baude bbaude@redhat.com 更新
August 2017, Originally compiled by Ryan Cole rycole@redhat.com
2017 年 8 月,最初由 Ryan Cole rycole@redhat.com 编译