Skip to content

Commit 8b37cf4

Browse files
authored
Update logging.mdx
1 parent 53f9ff4 commit 8b37cf4

File tree

1 file changed

+66
-27
lines changed

1 file changed

+66
-27
lines changed

vcluster/configure/vcluster-yaml/logging.mdx

Lines changed: 66 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -5,55 +5,94 @@ sidebar_position: 13
55
description: Configuration for setting structured logging options for vCluster.
66
---
77

8-
vCluster prints out structured logs to the console, by default. There are two log-encoding options provided: `console` and `json`.
8+
import Logging from '../../_partials/config/sleepMode.mdx'
99

10-
The default logging option is set to `console`.
10+
vCluster outputs structured logs that help you monitor and troubleshoot your virtual clusters. You can configure the log format to suit your monitoring and analysis tools and workflows.
1111

12-
## Configure logging
12+
## Configure log encoding
1313

14-
To choose the logging encoding for vCluster logs, you can set the `logging.encoding` field in the `vcluster.yaml` to
15-
one of the following values: `json` or `console`. For example:
16-
```yaml
17-
logging:
18-
encoding: json
19-
```
14+
You can set the log encoding format in your `vcluster.yaml` configuration:
2015

21-
:::note
22-
Setting `logging.encoding` value in vCluster.yaml only applies to the logs generated by vCluster and has no control over
23-
platform generated logs. So, make sure that you have set the appropriate logging format in platform as well that suits
24-
your requirements. Refer [platform logging](https://www.vcluster.com/docs/platform/administer/monitoring/metrics#configure-logging)
25-
for configuring logging in platform.
16+
<InterpolatedCodeBlock
17+
code={`logging:
18+
encoding: [[VAR:ENCODING:json]]`}
19+
language="yaml"
20+
/>
21+
22+
Select either `json` or `console` for the `encoding` value.
23+
24+
:::note Platform logging
25+
The `logging.encoding` setting only affects vCluster component logs. Platform-generated logs use a separate configuration.
2626
:::
2727

28-
### Console logging
28+
## Log encoding formats
29+
30+
vCluster supports two log encoding formats:
31+
32+
- [console](#console-format) (_Default_): Human-readable format ideal for development and manual log review.
33+
- [JSON](#json-format): Structured format for log aggregation and automated analysis.
2934

30-
The logs in this format include constant log messages, a human-readable timestamp, log levels, the file and line numberof the source caller, and with variables in the body:
35+
### Console format
36+
37+
The console format provides human-readable logs with timestamps, log levels, source locations, and contextual information:
3138

3239
```text
3340
2025-06-16 04:43:25 INFO license loader/inject.go:52 initializing license... {"component": "vcluster"}
3441
2025-06-16 04:43:25 INFO license loader/inject.go:59 detected license type {"component": "vcluster", "licenseType": "Online"}
3542
2025-06-16 04:43:29 INFO online/license.go:141 Enabled features: {"component": "vcluster"}
3643
2025-06-16 04:43:29 INFO online/license.go:146 rancher-integration {"component": "vcluster"}
37-
3844
```
3945

40-
### JSON logging
46+
The console format is best suited for local development and testing, where developers benefit from quick, readable output. It also works well for manual log review and debugging, especially when troubleshooting issues directly in the terminal. Choose this format in environments where human readability is more important than structured log parsing.
4147

42-
In addition to `console` logging, vCluster also supports printing logs encoded in JSON format.
48+
### JSON format
4349

44-
This output format is helpful for structured logging, which allows you to search and filter logs easily.
50+
The JSON format structures log data for programmatic processing and integration with log management systems:
4551

46-
```text
52+
```json
4753
{"level":"info","ts":1750160027.442782,"logger":"license","caller":"loader/inject.go:52","msg":"initializing license...","component":"vcluster"}
4854
{"level":"info","ts":1750160027.4497442,"logger":"license","caller":"loader/inject.go:59","msg":"detected license type","component":"vcluster","licenseType":"Online"}
4955
{"level":"info","ts":1750160029.1307533,"caller":"online/license.go:141","msg":"Enabled features:","component":"vcluster"}
5056
{"level":"info","ts":1750160029.1307998,"caller":"online/license.go:146","msg":"connected-clusters","component":"vcluster"}
5157
```
5258

53-
The JSON encoded logs contain at least the following fields:
59+
#### JSON log fields
60+
61+
Each JSON log entry contains the following standard fields:
62+
63+
| Field | Type | Description |
64+
|-------|------|-------------|
65+
| `level` | string | Log level (`info`, `warn`, `error`, `debug`) |
66+
| `ts` | number | Unix timestamp (seconds since epoch) |
67+
| `caller`| string | Source file and line number |
68+
| `msg` | string | Log message content |
69+
| `component` | string | vCluster component that generated the log |
70+
71+
Additional fields might be displayed based on context and log content.
72+
73+
The JSON format is ideal for production environments where logs need to be parsed and processed automatically. It works well with log aggregation tools like Elasticsearch or Splunk and supports automated analysis, alerting, and integration with monitoring platforms such as Prometheus and Grafana.
74+
75+
## Examples
76+
77+
### Development environment
78+
79+
For local development with human-readable logs:
80+
81+
```yaml
82+
logging:
83+
encoding: console
84+
```
85+
86+
### Production environment
87+
88+
For production with structured logging and monitoring:
89+
90+
```yaml
91+
logging:
92+
encoding: json
93+
```
94+
95+
## Config reference
96+
97+
<Logging />
5498
55-
- `level`: The log level of the message
56-
- `ts`: The timestamp of the message (floating-point number of seconds since the Unix epoch)
57-
- `caller`: The file and line number of the message
58-
- `msg`: The message itself
59-
- `component`: The vCluster component that emitted the message

0 commit comments

Comments
 (0)