Skip to content

Commit 57130b8

Browse files
committed
DOCS-1676: Add fine-grained logging controls
1 parent c905a64 commit 57130b8

File tree

1 file changed

+40
-11
lines changed

1 file changed

+40
-11
lines changed

Diff for: docs/architecture/viam-server.md

+40-11
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,48 @@ maintenance : {
100100

101101
### Logging
102102

103-
Log messages written appear under the [**LOGS** tab](/cloud/machines/#logs) for the machine running the module.
104-
105-
#### Debugging
103+
Log messages appear under the [**LOGS** tab](/cloud/machines/#logs) for a machine.
106104

107105
The default log level for `viam-server` and any running resources is `"Info"`.
108106

107+
You can set log levels for individual resources by adding the `log_configuration` option to the resources' JSON configuration:
108+
109+
```json
110+
"log_configuration": {
111+
"level": "Debug"
112+
},
113+
"attributes": { ... }
114+
```
115+
116+
Alternatively, you can configure logs for all machine resources, inside your machine config.
117+
To specify the log level for a specific resource, add the `log` field to your machine config:
118+
119+
For example:
120+
121+
```json
122+
"log": [
123+
     {
124+
       "pattern": "rdk.resource_manager",
125+
       "level": "info",
126+
     },{
127+
       "pattern": "rdk.resource_manager.*",
128+
       "level": "debug",
129+
     }
130+
  ]
131+
```
132+
133+
<!-- prettier-ignore -->
134+
| Attribute | Description |
135+
| --------- | ----------- |
136+
| `pattern` | A regular expression (regex) pattern matching one or more resources. |
137+
| `level` | The log level: `"debug"`, `"info"`, `"warn"`, or `"error"`. |
138+
139+
Patterns are processed from top to bottom.
140+
If multiple patterns apply, the last pattern to be processed will apply.
141+
If log configurations are applied at a resource level using the `log_configuration` field, these take precedence over log levels applied in the `log` field of the machine configuration.
142+
143+
#### Debugging
144+
109145
You can enable debug level logs in two ways:
110146

111147
- Start `viam-server` with the `-debug` option.
@@ -118,14 +154,7 @@ You can enable debug level logs in two ways:
118154
}
119155
```
120156

121-
To enable debug level logs for specific resources you can add the `log_configuration` option to the resources' JSON configuration:
122-
123-
```json
124-
"log_configuration": {
125-
"level": "Debug"
126-
},
127-
"attributes": { ... }
128-
```
157+
Enabling debug level logs will take precedence over all logging configuration set using the `log` field on a machine or the `log_configuration` field on a resource.
129158

130159
### Shutdown
131160

0 commit comments

Comments
 (0)