Debug Logs
Ability to stream debug logs from a device over MQTT, websocket or UDP to diagnose problems is supported. Information about your current configuration of this feature can be found through Sys.GetConfig. Log streams are disabled by default. To change the configuration and enable logging, use the RPC method Sys.SetConfig.
Every log line is stored in a circular buffer with limited size before sending. If too many lines are emitted simultaneously or in rapid succession, the oldest may be discarded and not streamed at all!
Logs over MQTT
When enabled, debug log is published to the topic <shelly-id>/debug/log.
Example:
Example log snippetshellypro4pm-f008d1d8b8b8 0 1630591789.944 2|mgos_sys_config.c:232 Loading conf3.json
shellypro4pm-f008d1d8b8b8 1 1630591790.208 2|mgos_sys_config.c:232 Loading conf9.json
shellypro4pm-f008d1d8b8b8 2 1630591790.346 2|mgos_sys_config.c:232 Loading conf3.json
shellypro4pm-f008d1d8b8b8 3 1630591790.732 2|mgos_sys_config.c:174 Saved to conf9.json
shellypro4pm-f008d1d8b8b8 4 1630591790.750 2|shelly_notifications:79 NotifyEvent: 'localweb266' (WS_in) -> ok? 1
shellypro4pm-f008d1d8b8b8 5 1630591790.758 2|shelly_notifications:79 NotifyEvent: 'shelly.cloud' (SHC) -> ok? 1
shellypro4pm-f008d1d8b8b8 6 1630591790.768 2|shelly_notifications:79 NotifyEvent: 'shellypro4pm-f008d1d8b8b8/events' (MQTT) -> ok?
Logs over Websocket
Prior to version 1.0.0 access to log streams over websocket is not restricted, even when authentication is enabled!
When enabled, device log is streamed to ws://<SHELLY_HOST>/debug/log (for example, ws://10.33.52.133/debug/log). When disabled, logging is stopped and all open websocket debug connections are closed. Up to three websocket debug connections can be opened simultaneously.
The log is streamed as JSON objects that have the following properties:
ts: number, unix timestamp (in UTC)level: number, log level. Range of values:0-> error,1-> warn,2-> info,3-> debug,4-> verbose debugdata: string, the log message
Example:
{
"ts": 1630322411.725,
"level": 2,
"data": "shelly_switch.cpp:1096 change voltage\n"
}
Logs over UDP
When enabled, device log is streamed to the address (<host>:<port>) specified in the configuration of the System component of your device.
You can observe the streamed log using:
mos console --port udp://host:port
Example:
Example log snippet[Sep 2 17:28:00.811] shellypro4pm-f008d1d8b8b8 66 366.319 2 2|shelly_switch.cpp:1096 change aenergy
[Sep 2 17:28:00.813] shellypro4pm-f008d1d8b8b8 67 366.327 2 2|shelly_notifications:79 NotifyStatus: 'localweb247' (WS_in) -> ok? 1
[Sep 2 17:28:00.822] shellypro4pm-f008d1d8b8b8 68 366.338 2 2|shelly_notifications:79 NotifyStatus: 'shellypro4pm-f008d1d8b8b8/events' (MQTT) -> ok? 1
[Sep 2 17:28:00.822] shellypro4pm-f008d1d8b8b8 69 366.352 2 2|shelly_switch.cpp:1096 change aenergy
[Sep 2 17:28:00.823] shellypro4pm-f008d1d8b8b8 70 366.361 2 2|shelly_notifications:79 NotifyStatus: 'localweb247' (WS_in) -> ok? 1
Persistent logs stored on filesystem
When enabled, device log is saved to a rotating set of files on the device flash.
You can inspect log files using the following HTTP endpoints:
http://<SHELLY_HOST>/debug/logsdisplays a list of log files in HTML form as clickable links, allowing inspecting individual log files in a web browser.http://<SHELLY_HOST>/debug/log?n=<N>&f=<0|1>outputs the lastN(100 by default) lines from all log files on the device.
When f=0 is provided, the HTTP connection is closed immediately after that.
When f=1 is provided, data is appended as new lines are logged.
curl http://<SHELLY_HOST>/debug/log?n=10&f=1
Example:
Example log snippet[Mar 06 13:49:40.649] INFO: shos_rpc_inst.c:230 webhook.list via WS_in 10.42.0.73:63202
[Mar 06 13:49:40.652] INFO: shos_rpc_inst.c:230 webhook.listsupported via WS_in 10.42.0.73:63202
[Mar 06 13:49:40.653] INFO: shos_rpc_inst.c:230 kvs.getmany via WS_in 10.42.0.73:63202
[Mar 06 13:49:40.654] INFO: shos_rpc_inst.c:230 schedule.list via WS_in 10.42.0.73:63202
[Mar 06 13:49:40.656] INFO: shos_rpc_inst.c:230 bthome.getobjectinfos via WS_in 10.42.0.73:63202
[Mar 06 13:49:40.658] INFO: shos_init.c:86 New min heap free: 137068
[Mar 06 13:49:40.730] INFO: shelly_debug.cpp:183 Streaming logs to 10.42.0.73:63204
[Mar 06 13:49:57.136] INFO: shos_rpc_inst.c:230 Shelly.GetConfig via WS_in 10.42.1.16:39236
[Mar 06 13:49:57.208] INFO: shos_rpc_inst.c:230 Shelly.GetStatus via WS_in 10.42.1.16:39236
[Mar 06 13:49:57.227] INFO: shos_rpc_inst.c:230 Script.List via WS_in 10.42.1.16:39236
[Mar 06 14:09:51.525] INFO: shelly_debug.cpp:183 Streaming logs to 10.42.0.218:33334
...