You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/architecture/viam-server.md
+40-11
Original file line number
Diff line number
Diff line change
@@ -100,12 +100,48 @@ maintenance : {
100
100
101
101
### Logging
102
102
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.
106
104
107
105
The default log level for `viam-server` and any running resources is `"Info"`.
108
106
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
+
109
145
You can enable debug level logs in two ways:
110
146
111
147
- Start `viam-server` with the `-debug` option.
@@ -118,14 +154,7 @@ You can enable debug level logs in two ways:
118
154
}
119
155
```
120
156
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.
0 commit comments