|
1
|
import { Table, Note, CodeTabs, CodeTab } from "docs-ui" |
|
2
|
|
|
3
|
export const metadata = { |
|
4
|
title: `logs Command - Medusa Cloud CLI Reference`, |
|
5
|
} |
|
6
|
|
|
7
|
# {metadata.title} |
|
8
|
|
|
9
|
Fetch runtime logs for a Cloud environment's backend or storefront. |
|
10
|
|
|
11
|
<CodeTabs group="cli-auth"> |
|
12
|
<CodeTab label="With Flags" value="flags"> |
|
13
|
|
|
14
|
```bash |
|
15
|
mcloud logs --organization org_123 --project proj_123 --environment env_123 |
|
16
|
``` |
|
17
|
|
|
18
|
</CodeTab> |
|
19
|
<CodeTab label="Using mcloud use" value="use"> |
|
20
|
|
|
21
|
```bash |
|
22
|
# Run once: mcloud use --organization org_123 --project proj_123 --environment env_123 |
|
23
|
|
|
24
|
mcloud logs |
|
25
|
``` |
|
26
|
|
|
27
|
</CodeTab> |
|
28
|
</CodeTabs> |
|
29
|
|
|
30
|
By default, the command retrieves the last 500 log lines from the past 15 |
|
31
|
minutes and prints them to the terminal. You can narrow the output with |
|
32
|
filters for time range, deployment, source, metadata, and search terms, or |
|
33
|
stream new log lines continuously with `--follow`. |
|
34
|
|
|
35
|
## Options |
|
36
|
|
|
37
|
<Table> |
|
38
|
<Table.Header> |
|
39
|
<Table.Row> |
|
40
|
<Table.HeaderCell> |
|
41
|
Option |
|
42
|
</Table.HeaderCell> |
|
43
|
<Table.HeaderCell> |
|
44
|
Description |
|
45
|
</Table.HeaderCell> |
|
46
|
<Table.HeaderCell> |
|
47
|
Required |
|
48
|
</Table.HeaderCell> |
|
49
|
<Table.HeaderCell> |
|
50
|
Default |
|
51
|
</Table.HeaderCell> |
|
52
|
</Table.Row> |
|
53
|
</Table.Header> |
|
54
|
<Table.Body> |
|
55
|
<Table.Row> |
|
56
|
<Table.Cell> |
|
57
|
|
|
58
|
`-o <id>`, `--organization <id>` |
|
59
|
|
|
60
|
</Table.Cell> |
|
61
|
<Table.Cell> |
|
62
|
|
|
63
|
The [ID of the organization](../organizations/page.mdx#find-organization-id) that the environment belongs to. |
|
64
|
|
|
65
|
</Table.Cell> |
|
66
|
<Table.Cell> |
|
67
|
|
|
68
|
Required when authenticated without an organization access key. |
|
69
|
|
|
70
|
</Table.Cell> |
|
71
|
<Table.Cell> |
|
72
|
|
|
73
|
Falls back to the organization in the [active context](../use/page.mdx#set-the-active-context), if set. |
|
74
|
|
|
75
|
</Table.Cell> |
|
76
|
</Table.Row> |
|
77
|
<Table.Row> |
|
78
|
<Table.Cell> |
|
79
|
|
|
80
|
`-p <id-or-handle>`, `--project <id-or-handle>` |
|
81
|
|
|
82
|
</Table.Cell> |
|
83
|
<Table.Cell> |
|
84
|
|
|
85
|
[The ID of the project](../projects/page.mdx#find-project-ids-and-handles) that the environment belongs to. |
|
86
|
|
|
87
|
</Table.Cell> |
|
88
|
<Table.Cell> |
|
89
|
|
|
90
|
Yes |
|
91
|
|
|
92
|
</Table.Cell> |
|
93
|
<Table.Cell> |
|
94
|
|
|
95
|
Falls back to the project in the [active context](../use/page.mdx#set-the-active-context), if set. |
|
96
|
|
|
97
|
</Table.Cell> |
|
98
|
</Table.Row> |
|
99
|
<Table.Row> |
|
100
|
<Table.Cell> |
|
101
|
|
|
102
|
`-e <handle>`, `--environment <handle>` |
|
103
|
|
|
104
|
</Table.Cell> |
|
105
|
<Table.Cell> |
|
106
|
|
|
107
|
[The handle of the environment](../environments/page.mdx#find-environment-handles) to fetch logs for. |
|
108
|
|
|
109
|
</Table.Cell> |
|
110
|
<Table.Cell> |
|
111
|
|
|
112
|
Yes |
|
113
|
|
|
114
|
</Table.Cell> |
|
115
|
<Table.Cell> |
|
116
|
|
|
117
|
Falls back to the environment in the [active context](../use/page.mdx#set-the-active-context), if set. |
|
118
|
|
|
119
|
</Table.Cell> |
|
120
|
</Table.Row> |
|
121
|
<Table.Row> |
|
122
|
<Table.Cell> |
|
123
|
|
|
124
|
`-f`, `--follow` |
|
125
|
|
|
126
|
</Table.Cell> |
|
127
|
<Table.Cell> |
|
128
|
|
|
129
|
Poll for new log lines continuously instead of fetching a bounded time |
|
130
|
window. The command runs until you stop it with <Kbd>CTRL</Kbd>+<Kbd>C</Kbd>. |
|
131
|
Incompatible with `--json`. |
|
132
|
|
|
133
|
</Table.Cell> |
|
134
|
<Table.Cell> |
|
135
|
|
|
136
|
No |
|
137
|
|
|
138
|
</Table.Cell> |
|
139
|
<Table.Cell> |
|
140
|
|
|
141
|
`false` (the command exits after fetching a recent time window) |
|
142
|
|
|
143
|
</Table.Cell> |
|
144
|
</Table.Row> |
|
145
|
<Table.Row> |
|
146
|
<Table.Cell> |
|
147
|
|
|
148
|
`--limit <number>` |
|
149
|
|
|
150
|
</Table.Cell> |
|
151
|
<Table.Cell> |
|
152
|
|
|
153
|
Maximum number of log lines to retrieve. Only used in non-follow mode. |
|
154
|
Minimum: `1`, maximum: `5000`. |
|
155
|
|
|
156
|
</Table.Cell> |
|
157
|
<Table.Cell> |
|
158
|
|
|
159
|
No |
|
160
|
|
|
161
|
</Table.Cell> |
|
162
|
<Table.Cell> |
|
163
|
|
|
164
|
`500` |
|
165
|
|
|
166
|
</Table.Cell> |
|
167
|
</Table.Row> |
|
168
|
<Table.Row> |
|
169
|
<Table.Cell> |
|
170
|
|
|
171
|
`--from <ISO8601>` |
|
172
|
|
|
173
|
</Table.Cell> |
|
174
|
<Table.Cell> |
|
175
|
|
|
176
|
Start of the time range as an ISO 8601 timestamp. Only used in |
|
177
|
non-follow mode. For example, `2026-04-22T10:00:00Z` for April 22, 2026 at 10:00am UTC. |
|
178
|
|
|
179
|
</Table.Cell> |
|
180
|
<Table.Cell> |
|
181
|
|
|
182
|
No |
|
183
|
|
|
184
|
</Table.Cell> |
|
185
|
<Table.Cell> |
|
186
|
|
|
187
|
15 minutes ago |
|
188
|
|
|
189
|
</Table.Cell> |
|
190
|
</Table.Row> |
|
191
|
<Table.Row> |
|
192
|
<Table.Cell> |
|
193
|
|
|
194
|
`--to <ISO8601>` |
|
195
|
|
|
196
|
</Table.Cell> |
|
197
|
<Table.Cell> |
|
198
|
|
|
199
|
End of the time range as an ISO 8601 timestamp. Only used in |
|
200
|
non-follow mode; ignored with `--follow`. Must be later than |
|
201
|
`--from`. If `--to` is before 15 minutes ago, you must also specify `--from` to define a valid time window. |
|
202
|
|
|
203
|
</Table.Cell> |
|
204
|
<Table.Cell> |
|
205
|
|
|
206
|
No |
|
207
|
|
|
208
|
</Table.Cell> |
|
209
|
<Table.Cell> |
|
210
|
|
|
211
|
now |
|
212
|
|
|
213
|
</Table.Cell> |
|
214
|
</Table.Row> |
|
215
|
<Table.Row> |
|
216
|
<Table.Cell> |
|
217
|
|
|
218
|
`--search <string>` |
|
219
|
|
|
220
|
</Table.Cell> |
|
221
|
<Table.Cell> |
|
222
|
|
|
223
|
Filter log lines by a substring. Behaves the same as the search bar |
|
224
|
in the Cloud dashboard logs view. |
|
225
|
|
|
226
|
</Table.Cell> |
|
227
|
<Table.Cell> |
|
228
|
|
|
229
|
No |
|
230
|
|
|
231
|
</Table.Cell> |
|
232
|
<Table.Cell> |
|
233
|
|
|
234
|
\- |
|
235
|
|
|
236
|
</Table.Cell> |
|
237
|
</Table.Row> |
|
238
|
<Table.Row> |
|
239
|
<Table.Cell> |
|
240
|
|
|
241
|
`--deployment <id>` |
|
242
|
|
|
243
|
</Table.Cell> |
|
244
|
<Table.Cell> |
|
245
|
|
|
246
|
Filter log lines by deployment or build ID. When a build ID is passed, the CLI resolves it to that build's latest deployment. |
|
247
|
|
|
248
|
</Table.Cell> |
|
249
|
<Table.Cell> |
|
250
|
|
|
251
|
No |
|
252
|
|
|
253
|
</Table.Cell> |
|
254
|
<Table.Cell> |
|
255
|
|
|
256
|
\- |
|
257
|
|
|
258
|
</Table.Cell> |
|
259
|
</Table.Row> |
|
260
|
<Table.Row> |
|
261
|
<Table.Cell> |
|
262
|
|
|
263
|
`--source <string>` |
|
264
|
|
|
265
|
</Table.Cell> |
|
266
|
<Table.Cell> |
|
267
|
|
|
268
|
Filter log lines by source. Repeatable. Pass the flag multiple times |
|
269
|
to include logs from multiple sources. |
|
270
|
|
|
271
|
</Table.Cell> |
|
272
|
<Table.Cell> |
|
273
|
|
|
274
|
No |
|
275
|
|
|
276
|
</Table.Cell> |
|
277
|
<Table.Cell> |
|
278
|
|
|
279
|
\- |
|
280
|
|
|
281
|
</Table.Cell> |
|
282
|
</Table.Row> |
|
283
|
<Table.Row> |
|
284
|
<Table.Cell> |
|
285
|
|
|
286
|
`--metadata <key=value>` |
|
287
|
|
|
288
|
</Table.Cell> |
|
289
|
<Table.Cell> |
|
290
|
|
|
291
|
Filter log lines by a metadata field using an "in" filter. Repeatable. |
|
292
|
Pass the flag multiple times. Repeating the same key merges the |
|
293
|
values into a single filter. See [Available Metadata Keys](#available-metadata-keys) for the supported field names. |
|
294
|
|
|
295
|
</Table.Cell> |
|
296
|
<Table.Cell> |
|
297
|
|
|
298
|
No |
|
299
|
|
|
300
|
</Table.Cell> |
|
301
|
<Table.Cell> |
|
302
|
|
|
303
|
\- |
|
304
|
|
|
305
|
</Table.Cell> |
|
306
|
</Table.Row> |
|
307
|
<Table.Row> |
|
308
|
<Table.Cell> |
|
309
|
|
|
310
|
`--type <backend|storefront>` |
|
311
|
|
|
312
|
</Table.Cell> |
|
313
|
<Table.Cell> |
|
314
|
|
|
315
|
Log stream type to query. |
|
316
|
|
|
317
|
</Table.Cell> |
|
318
|
<Table.Cell> |
|
319
|
|
|
320
|
No |
|
321
|
|
|
322
|
</Table.Cell> |
|
323
|
<Table.Cell> |
|
324
|
|
|
325
|
`backend` |
|
326
|
|
|
327
|
</Table.Cell> |
|
328
|
</Table.Row> |
|
329
|
<Table.Row> |
|
330
|
<Table.Cell> |
|
331
|
|
|
332
|
`--json` |
|
333
|
|
|
334
|
</Table.Cell> |
|
335
|
<Table.Cell> |
|
336
|
|
|
337
|
Print the result as JSON instead of formatted text. Not available with |
|
338
|
`--follow`. |
|
339
|
|
|
340
|
</Table.Cell> |
|
341
|
<Table.Cell> |
|
342
|
|
|
343
|
No |
|
344
|
|
|
345
|
</Table.Cell> |
|
346
|
<Table.Cell> |
|
347
|
|
|
348
|
`false` |
|
349
|
|
|
350
|
</Table.Cell> |
|
351
|
</Table.Row> |
|
352
|
</Table.Body> |
|
353
|
</Table> |
|
354
|
|
|
355
|
--- |
|
356
|
|
|
357
|
## Process Logs in an Agentic Workflow |
|
358
|
|
|
359
|
{/* TODO revisit once we have skills */} |
|
360
|
|
|
361
|
Use `--json` to get machine-readable output that you can pass to `jq` or |
|
362
|
other tools for filtering and analysis: |
|
363
|
|
|
364
|
<CodeTabs group="cli-auth"> |
|
365
|
<CodeTab label="With Flags" value="flags"> |
|
366
|
|
|
367
|
```bash |
|
368
|
mcloud logs \ |
|
369
|
--project proj_123 \ |
|
370
|
--environment production \ |
|
371
|
--search "500" \ |
|
372
|
--json | jq '.[] | .message' |
|
373
|
``` |
|
374
|
|
|
375
|
</CodeTab> |
|
376
|
<CodeTab label="Using mcloud use" value="use"> |
|
377
|
|
|
378
|
```bash |
|
379
|
# Run once: mcloud use --project proj_123 --environment production |
|
380
|
|
|
381
|
mcloud logs --search "500" --json | jq '.[] | .message' |
|
382
|
``` |
|
383
|
|
|
384
|
</CodeTab> |
|
385
|
</CodeTabs> |
|
386
|
|
|
387
|
Set the active context once with [`mcloud use`](../use/page.mdx) to avoid repeating project and environment flags across multiple commands: |
|
388
|
|
|
389
|
```bash |
|
390
|
mcloud use --project proj_123 --environment production |
|
391
|
|
|
392
|
mcloud logs --search error --limit 500 --json |
|
393
|
mcloud logs --follow |
|
394
|
``` |
|
395
|
|
|
396
|
--- |
|
397
|
|
|
398
|
## Stream Live Logs |
|
399
|
|
|
400
|
Use `--follow` to tail an environment's logs continuously. This is useful |
|
401
|
when monitoring a deployment in progress or watching for errors in real time: |
|
402
|
|
|
403
|
<CodeTabs group="cli-auth"> |
|
404
|
<CodeTab label="With Flags" value="flags"> |
|
405
|
|
|
406
|
```bash |
|
407
|
mcloud logs \ |
|
408
|
--organization org_123 \ |
|
409
|
--project proj_123 \ |
|
410
|
--environment env_123 \ |
|
411
|
--follow |
|
412
|
``` |
|
413
|
|
|
414
|
</CodeTab> |
|
415
|
<CodeTab label="Using mcloud use" value="use"> |
|
416
|
|
|
417
|
```bash |
|
418
|
# Run once: mcloud use --organization org_123 --project proj_123 --environment env_123 |
|
419
|
|
|
420
|
mcloud logs --follow |
|
421
|
``` |
|
422
|
|
|
423
|
</CodeTab> |
|
424
|
</CodeTabs> |
|
425
|
|
|
426
|
The command polls for new lines until you stop it with `Ctrl+C`. |
|
427
|
|
|
428
|
<Note> |
|
429
|
|
|
430
|
`--follow` is incompatible with `--json`. To process logs programmatically |
|
431
|
in a script, use a bounded time-window fetch instead. |
|
432
|
|
|
433
|
</Note> |
|
434
|
|
|
435
|
--- |
|
436
|
|
|
437
|
## Search for Errors |
|
438
|
|
|
439
|
If you're looking for errors in the logs, use `--search` to filter log lines by a substring. This works the same |
|
440
|
as the search bar in the Cloud dashboard logs view: |
|
441
|
|
|
442
|
<CodeTabs group="cli-auth"> |
|
443
|
<CodeTab label="With Flags" value="flags"> |
|
444
|
|
|
445
|
```bash |
|
446
|
mcloud logs \ |
|
447
|
--organization org_123 \ |
|
448
|
--project proj_123 \ |
|
449
|
--environment env_123 \ |
|
450
|
--search error \ |
|
451
|
--limit 1000 |
|
452
|
``` |
|
453
|
|
|
454
|
</CodeTab> |
|
455
|
<CodeTab label="Using mcloud use" value="use"> |
|
456
|
|
|
457
|
```bash |
|
458
|
# Run once: mcloud use --organization org_123 --project proj_123 --environment env_123 |
|
459
|
|
|
460
|
mcloud logs --search error --limit 1000 |
|
461
|
``` |
|
462
|
|
|
463
|
</CodeTab> |
|
464
|
</CodeTabs> |
|
465
|
|
|
466
|
Alternatively, if you're looking for HTTP calls that resulted in 500 or other error status codes, use the `--metadata` filter to find log lines with `status=500`: |
|
467
|
|
|
468
|
<CodeTabs group="cli-auth"> |
|
469
|
<CodeTab label="With Flags" value="flags"> |
|
470
|
|
|
471
|
```bash |
|
472
|
mcloud logs \ |
|
473
|
--organization org_123 \ |
|
474
|
--project proj_123 \ |
|
475
|
--environment env_123 \ |
|
476
|
--metadata status=500 \ |
|
477
|
--limit 1000 |
|
478
|
``` |
|
479
|
|
|
480
|
</CodeTab> |
|
481
|
<CodeTab label="Using mcloud use" value="use"> |
|
482
|
|
|
483
|
```bash |
|
484
|
# Run once: mcloud use --organization org_123 --project proj_123 --environment env_123 |
|
485
|
|
|
486
|
mcloud logs --metadata status=500 --limit 1000 |
|
487
|
``` |
|
488
|
|
|
489
|
</CodeTab> |
|
490
|
</CodeTabs> |
|
491
|
|
|
492
|
### Available Metadata Keys |
|
493
|
|
|
494
|
`--metadata` filters on the structured fields of HTTP request log lines. Other log lines (such as your application's own log messages) may not have these fields, so a metadata filter only matches request logs. |
|
495
|
|
|
496
|
Backend logs (`--type backend`, the default) expose the following keys: |
|
497
|
|
|
498
|
<Table> |
|
499
|
<Table.Header> |
|
500
|
<Table.Row> |
|
501
|
<Table.HeaderCell> |
|
502
|
Key |
|
503
|
</Table.HeaderCell> |
|
504
|
<Table.HeaderCell> |
|
505
|
Description |
|
506
|
</Table.HeaderCell> |
|
507
|
</Table.Row> |
|
508
|
</Table.Header> |
|
509
|
<Table.Body> |
|
510
|
<Table.Row> |
|
511
|
<Table.Cell> |
|
512
|
|
|
513
|
`status` |
|
514
|
|
|
515
|
</Table.Cell> |
|
516
|
<Table.Cell> |
|
517
|
|
|
518
|
HTTP response status code, such as `200` or `500`. |
|
519
|
|
|
520
|
</Table.Cell> |
|
521
|
</Table.Row> |
|
522
|
<Table.Row> |
|
523
|
<Table.Cell> |
|
524
|
|
|
525
|
`method` |
|
526
|
|
|
527
|
</Table.Cell> |
|
528
|
<Table.Cell> |
|
529
|
|
|
530
|
HTTP request method, such as `GET` or `POST`. |
|
531
|
|
|
532
|
</Table.Cell> |
|
533
|
</Table.Row> |
|
534
|
<Table.Row> |
|
535
|
<Table.Cell> |
|
536
|
|
|
537
|
`path` |
|
538
|
|
|
539
|
</Table.Cell> |
|
540
|
<Table.Cell> |
|
541
|
|
|
542
|
Request path, such as `/store/products`. |
|
543
|
|
|
544
|
</Table.Cell> |
|
545
|
</Table.Row> |
|
546
|
<Table.Row> |
|
547
|
<Table.Cell> |
|
548
|
|
|
549
|
`duration` |
|
550
|
|
|
551
|
</Table.Cell> |
|
552
|
<Table.Cell> |
|
553
|
|
|
554
|
Response time in milliseconds. |
|
555
|
|
|
556
|
</Table.Cell> |
|
557
|
</Table.Row> |
|
558
|
<Table.Row> |
|
559
|
<Table.Cell> |
|
560
|
|
|
561
|
`request_id` |
|
562
|
|
|
563
|
</Table.Cell> |
|
564
|
<Table.Cell> |
|
565
|
|
|
566
|
Request ID, useful to correlate a request with related error logs. |
|
567
|
|
|
568
|
</Table.Cell> |
|
569
|
</Table.Row> |
|
570
|
<Table.Row> |
|
571
|
<Table.Cell> |
|
572
|
|
|
573
|
`client_ip` |
|
574
|
|
|
575
|
</Table.Cell> |
|
576
|
<Table.Cell> |
|
577
|
|
|
578
|
IP address of the client that made the request. |
|
579
|
|
|
580
|
</Table.Cell> |
|
581
|
</Table.Row> |
|
582
|
<Table.Row> |
|
583
|
<Table.Cell> |
|
584
|
|
|
585
|
`user_agent` |
|
586
|
|
|
587
|
</Table.Cell> |
|
588
|
<Table.Cell> |
|
589
|
|
|
590
|
User agent of the client that made the request. |
|
591
|
|
|
592
|
</Table.Cell> |
|
593
|
</Table.Row> |
|
594
|
<Table.Row> |
|
595
|
<Table.Cell> |
|
596
|
|
|
597
|
`referrer` |
|
598
|
|
|
599
|
</Table.Cell> |
|
600
|
<Table.Cell> |
|
601
|
|
|
602
|
Referrer of the request. |
|
603
|
|
|
604
|
</Table.Cell> |
|
605
|
</Table.Row> |
|
606
|
<Table.Row> |
|
607
|
<Table.Cell> |
|
608
|
|
|
609
|
`response_size` |
|
610
|
|
|
611
|
</Table.Cell> |
|
612
|
<Table.Cell> |
|
613
|
|
|
614
|
Response size in bytes. |
|
615
|
|
|
616
|
</Table.Cell> |
|
617
|
</Table.Row> |
|
618
|
<Table.Row> |
|
619
|
<Table.Cell> |
|
620
|
|
|
621
|
`request_size` |
|
622
|
|
|
623
|
</Table.Cell> |
|
624
|
<Table.Cell> |
|
625
|
|
|
626
|
Request size in bytes. |
|
627
|
|
|
628
|
</Table.Cell> |
|
629
|
</Table.Row> |
|
630
|
<Table.Row> |
|
631
|
<Table.Cell> |
|
632
|
|
|
633
|
`http_version` |
|
634
|
|
|
635
|
</Table.Cell> |
|
636
|
<Table.Cell> |
|
637
|
|
|
638
|
HTTP version used for the request. |
|
639
|
|
|
640
|
</Table.Cell> |
|
641
|
</Table.Row> |
|
642
|
</Table.Body> |
|
643
|
</Table> |
|
644
|
|
|
645
|
Storefront logs (`--type storefront`) expose a subset of these keys: `status`, `method`, `path`, `duration`, and `level` (the highest log level of the request). |
|
646
|
|
|
647
|
--- |
|
648
|
|
|
649
|
## Fetch Logs for a Specific Deployment |
|
650
|
|
|
651
|
When a deployment fails, query the logs for that deployment directly using |
|
652
|
its ID. Find the build or deployment ID from [`mcloud deployments list`](../deployments/page.mdx#deployments-list) or the Cloud |
|
653
|
dashboard. Pass a build ID and the CLI resolves it to that build's latest deployment automatically. |
|
654
|
|
|
655
|
<Note title="Tip"> |
|
656
|
|
|
657
|
To fetch the build logs for a deployment instead of its runtime logs, use [`mcloud deployments build-logs`](../deployments/page.mdx#deployments-build-logs). |
|
658
|
|
|
659
|
</Note> |
|
660
|
|
|
661
|
<CodeTabs group="cli-auth"> |
|
662
|
<CodeTab label="With Flags" value="flags"> |
|
663
|
|
|
664
|
```bash |
|
665
|
mcloud logs \ |
|
666
|
--organization org_123 \ |
|
667
|
--project proj_123 \ |
|
668
|
--environment env_123 \ |
|
669
|
--deployment bld_01ABC123 |
|
670
|
``` |
|
671
|
|
|
672
|
</CodeTab> |
|
673
|
<CodeTab label="Using mcloud use" value="use"> |
|
674
|
|
|
675
|
```bash |
|
676
|
# Run once: mcloud use --organization org_123 --project proj_123 --environment env_123 |
|
677
|
|
|
678
|
mcloud logs --deployment bld_01ABC123 |
|
679
|
``` |
|
680
|
|
|
681
|
</CodeTab> |
|
682
|
</CodeTabs> |
|
683
|
|
|
684
|
--- |
|
685
|
|
|
686
|
## Specify Logs Time Range |
|
687
|
|
|
688
|
You can use the `--from` and `--to` flags to specify a time range for fetching logs instead of the default "last 15 minutes". |
|
689
|
|
|
690
|
Both flags accept ISO 8601 timestamps. When either or both are passed, the command retrieves all log lines within the time range, up to the maximum specified by `--limit` (default 500). |
|
691
|
|
|
692
|
### Example: Fetch Logs within a Time Range |
|
693
|
|
|
694
|
For example, to fetch logs from April 22, 2026 between 10:00am and 11:00am UTC: |
|
695
|
|
|
696
|
<CodeTabs group="cli-auth"> |
|
697
|
<CodeTab label="With Flags" value="flags"> |
|
698
|
|
|
699
|
```bash title="Fetch logs within an hour time range" |
|
700
|
mcloud logs \ |
|
701
|
--organization org_123 \ |
|
702
|
--project proj_123 \ |
|
703
|
--environment env_123 \ |
|
704
|
--to 2026-04-22T11:00:00Z |
|
705
|
``` |
|
706
|
|
|
707
|
</CodeTab> |
|
708
|
<CodeTab label="Using mcloud use" value="use"> |
|
709
|
|
|
710
|
```bash title="Fetch logs within an hour time range" |
|
711
|
# Run once: mcloud use --organization org_123 --project proj_123 --environment env_123 |
|
712
|
|
|
713
|
mcloud logs --to 2026-04-22T11:00:00Z |
|
714
|
``` |
|
715
|
|
|
716
|
</CodeTab> |
|
717
|
</CodeTabs> |
|
718
|
|
|
719
|
To increase the limit to 1000 log lines in that time range: |
|
720
|
|
|
721
|
<CodeTabs group="cli-auth"> |
|
722
|
<CodeTab label="With Flags" value="flags"> |
|
723
|
|
|
724
|
```bash title="Fetch logs within an hour time range with a higher limit" |
|
725
|
mcloud logs \ |
|
726
|
--organization org_123 \ |
|
727
|
--project proj_123 \ |
|
728
|
--environment env_123 \ |
|
729
|
--to 2026-04-22T11:00:00Z \ |
|
730
|
--limit 1000 |
|
731
|
``` |
|
732
|
|
|
733
|
</CodeTab> |
|
734
|
<CodeTab label="Using mcloud use" value="use"> |
|
735
|
|
|
736
|
```bash title="Fetch logs within an hour time range with a higher limit" |
|
737
|
# Run once: mcloud use --organization org_123 --project proj_123 --environment env_123 |
|
738
|
|
|
739
|
mcloud logs --to 2026-04-22T11:00:00Z --limit 1000 |
|
740
|
``` |
|
741
|
|
|
742
|
</CodeTab> |
|
743
|
</CodeTabs> |
|
744
|
|
|
745
|
### Example: Fetch Logs Starting from a Time Until Now |
|
746
|
|
|
747
|
To fetch logs starting from a specific time until now, pass `--from` without `--to`: |
|
748
|
|
|
749
|
<CodeTabs group="cli-auth"> |
|
750
|
<CodeTab label="With Flags" value="flags"> |
|
751
|
|
|
752
|
```bash title="Fetch logs starting from a specific time until now" |
|
753
|
mcloud logs \ |
|
754
|
--organization org_123 \ |
|
755
|
--project proj_123 \ |
|
756
|
--environment env_123 \ |
|
757
|
--from 2026-04-22T10:00:00Z |
|
758
|
``` |
|
759
|
|
|
760
|
</CodeTab> |
|
761
|
<CodeTab label="Using mcloud use" value="use"> |
|
762
|
|
|
763
|
```bash title="Fetch logs starting from a specific time until now" |
|
764
|
# Run once: mcloud use --organization org_123 --project proj_123 --environment env_123 |
|
765
|
|
|
766
|
mcloud logs --from 2026-04-22T10:00:00Z |
|
767
|
``` |
|
768
|
|
|
769
|
</CodeTab> |
|
770
|
</CodeTabs> |
|
771
|
|
|
772
|
### Example: Fetch Logs Until a Time in the Past |
|
773
|
|
|
774
|
To fetch logs until a certain time, pass `--to`. If that time is more than 15 minutes ago, you must also pass `--from` to define a valid time window. |
|
775
|
|
|
776
|
For example, to pass logs until 5 minutes ago, you don't need to specify `--from`: |
|
777
|
|
|
778
|
<CodeTabs group="cli-auth"> |
|
779
|
<CodeTab label="With Flags" value="flags"> |
|
780
|
|
|
781
|
```bash title="Fetch logs until a time that's within the last 15 minutes" |
|
782
|
mcloud logs \ |
|
783
|
--organization org_123 \ |
|
784
|
--project proj_123 \ |
|
785
|
--environment env_123 \ |
|
786
|
--to 2026-04-22T10:55:00Z # assuming now is 2026-04-22T11:00:00Z |
|
787
|
``` |
|
788
|
|
|
789
|
</CodeTab> |
|
790
|
<CodeTab label="Using mcloud use" value="use"> |
|
791
|
|
|
792
|
```bash title="Fetch logs until a time that's within the last 15 minutes" |
|
793
|
# Run once: mcloud use --organization org_123 --project proj_123 --environment env_123 |
|
794
|
|
|
795
|
mcloud logs --to 2026-04-22T10:55:00Z # assuming now is 2026-04-22T11:00:00Z |
|
796
|
``` |
|
797
|
|
|
798
|
</CodeTab> |
|
799
|
</CodeTabs> |
|
800
|
|
|
801
|
However, if you want to fetch logs until 20 minutes ago, you must also specify `--from` to define a valid time window: |
|
802
|
|
|
803
|
<CodeTabs group="cli-auth"> |
|
804
|
<CodeTab label="With Flags" value="flags"> |
|
805
|
|
|
806
|
```bash title="Fetch logs until a time that's more than 15 minutes ago, with a valid time window" |
|
807
|
mcloud logs \ |
|
808
|
--organization org_123 \ |
|
809
|
--project proj_123 \ |
|
810
|
--environment env_123 \ |
|
811
|
--from 2026-04-22T10:00:00Z \ |
|
812
|
--to 2026-04-22T10:40:00Z # assuming now is 2026-04-22T11:00:00Z |
|
813
|
``` |
|
814
|
|
|
815
|
</CodeTab> |
|
816
|
<CodeTab label="Using mcloud use" value="use"> |
|
817
|
|
|
818
|
```bash title="Fetch logs until a time that's more than 15 minutes ago, with a valid time window" |
|
819
|
# Run once: mcloud use --organization org_123 --project proj_123 --environment env_123 |
|
820
|
|
|
821
|
mcloud logs \ |
|
822
|
--from 2026-04-22T10:00:00Z \ |
|
823
|
--to 2026-04-22T10:40:00Z # assuming now is 2026-04-22T11:00:00Z |
|
824
|
``` |
|
825
|
|
|
826
|
</CodeTab> |
|
827
|
</CodeTabs> |
|
828
|
|
|
829
|
--- |
|
830
|
|
|
831
|
## Filter Storefront Logs |
|
832
|
|
|
833
|
By default, `mcloud logs` fetches backend logs. To query storefront logs, |
|
834
|
pass `--type storefront`: |
|
835
|
|
|
836
|
<CodeTabs group="cli-auth"> |
|
837
|
<CodeTab label="With Flags" value="flags"> |
|
838
|
|
|
839
|
```bash |
|
840
|
mcloud logs \ |
|
841
|
--organization org_123 \ |
|
842
|
--project proj_123 \ |
|
843
|
--environment env_123 \ |
|
844
|
--type storefront |
|
845
|
``` |
|
846
|
|
|
847
|
</CodeTab> |
|
848
|
<CodeTab label="Using mcloud use" value="use"> |
|
849
|
|
|
850
|
```bash |
|
851
|
# Run once: mcloud use --organization org_123 --project proj_123 --environment env_123 |
|
852
|
|
|
853
|
mcloud logs --type storefront |
|
854
|
``` |
|
855
|
|
|
856
|
</CodeTab> |
|
857
|
</CodeTabs> |
|
858
|
|
|
859
|
You can also specify any of the other filters and options with storefront logs, such as `--follow` or `--search`. |