mcloud-logs
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseCloud CLI: Logs Command
Cloud CLI:日志命令
Execute to fetch runtime logs for a Cloud environment's backend or storefront.
mcloud logs执行命令以获取云环境中后端或店面的运行时日志。
mcloud logsConstraints
约束条件
- and
--followare incompatible. For programmatic log analysis, use bounded time windows with--json/--fromand--to.--json - streams until interrupted with
--follow— do not use in scripts or pipelines.Ctrl+C - Default retrieves the last 500 log lines from the past 15 minutes.
- 与
--follow参数互斥。如需进行程序化日志分析,请结合--json/--from参数指定时间范围并使用--to格式输出。--json - 会持续流式传输日志,直到按下
--follow中断——请勿在脚本或流水线中使用该参数。Ctrl+C - 默认会获取过去15分钟内的最后500条日志记录。
Command
命令
bash
mcloud logs \
--organization <org-id> \
--project <project-id-or-handle> \
--environment <environment-handle> \
[options]bash
mcloud logs \
--organization <org-id> \
--project <project-id-or-handle> \
--environment <environment-handle> \
[options]Options
参数选项
| Option | Description | Default |
|---|---|---|
| Organization ID | Active context |
| Project ID or handle | Active context |
| Environment handle | Active context |
| Stream logs continuously (incompatible with | |
| Max log lines (non-follow mode only) | |
| Start of time range (e.g. | 15 minutes ago |
| End of time range; if >15 min ago, must also pass | now |
| Filter by substring (same as dashboard search bar) | — |
| Filter by deployment or build ID | — |
| Filter by source (repeatable) | — |
| Filter by metadata field (repeatable; same key merges values) | — |
| Log stream to query | |
| Output as JSON (incompatible with | |
| 参数选项 | 说明 | 默认值 |
|---|---|---|
| 组织ID | 当前上下文 |
| 项目ID或标识 | 当前上下文 |
| 环境标识 | 当前上下文 |
| 持续流式传输日志(与 | |
| 最大日志行数(仅非跟随模式可用) | |
| 时间范围起始点(例如 | 15分钟前 |
| 时间范围结束点;若结束点早于15分钟前,必须同时指定 | 当前时间 |
| 按子字符串过滤(与控制台搜索栏功能一致) | — |
| 按部署或构建ID过滤 | — |
| 按来源过滤(可重复指定) | — |
| 按元数据字段过滤(可重复指定;相同键会合并值) | — |
| 要查询的日志流类型 | |
| 以JSON格式输出(与 | |
Examples
示例
bash
undefinedbash
undefinedBasic log fetch (last 500 lines, last 15 min)
基础日志获取(最近15分钟的最后500条记录)
mcloud logs --json
mcloud logs --json
Search for errors
搜索错误日志
mcloud logs --search error --limit 1000 --json
mcloud logs --search error --limit 1000 --json
Filter for HTTP 500 errors via metadata
通过元数据过滤HTTP 500错误日志
mcloud logs --metadata status=500 --limit 1000 --json
mcloud logs --metadata status=500 --limit 1000 --json
Logs for a specific deployment (build or deployment ID)
获取特定部署的日志(构建或部署ID)
mcloud logs --deployment bld_01ABC123 --json
mcloud logs --deployment bld_01ABC123 --json
Structured output for agent analysis
结构化输出用于Agent分析
mcloud logs --search error --json | jq '.[] | {timestamp, source, message}'
mcloud logs --search error --json | jq '.[] | {timestamp, source, message}'
Storefront logs
店面日志
mcloud logs --type storefront --json
mcloud logs --type storefront --json
Stream live logs (human-readable, not for scripts)
流式传输实时日志(适合人类阅读,不用于脚本)
mcloud logs --follow
mcloud logs --follow
Logs within a specific time range
获取特定时间范围内的日志
mcloud logs --from 2026-04-22T10:00:00Z --to 2026-04-22T11:00:00Z --limit 1000 --json
mcloud logs --from 2026-04-22T10:00:00Z --to 2026-04-22T11:00:00Z --limit 1000 --json
Logs from a time until now
获取从指定时间到当前的日志
mcloud logs --from 2026-04-22T10:00:00Z --json
mcloud logs --from 2026-04-22T10:00:00Z --json
Multiple source filters
多来源过滤
mcloud logs --source api --source worker --json
mcloud logs --source api --source worker --json
Multiple metadata filters (HTTP 4xx and 5xx)
多元数据过滤(HTTP 4xx和5xx状态码)
mcloud logs --metadata status=400 --metadata status=500 --limit 500 --json
undefinedmcloud logs --metadata status=400 --metadata status=500 --limit 500 --json
undefinedTime Range Notes
时间范围说明
- Default window is the past 15 minutes.
- Pass without
--fromto fetch from a time until now.--to - Pass without
--toonly if--fromis within the last 15 minutes; otherwise also pass--to.--from - Both and
--fromaccept ISO 8601 timestamps.--to
- 默认时间窗口为过去15分钟。
- 仅指定而不指定
--from,将获取从指定时间到当前的日志。--to - 仅当在过去15分钟内时,才可单独指定
--to;否则必须同时指定--to。--from - 和
--from均支持ISO 8601格式的时间戳。--to