Hi all,
this is a short (~ 5 min) tutorial how to watch your logs remote (from local network) and live with Visual Studio Code and Samba. “Live” means that the log is updated automatically every second so that you don’t have to reopen it all the time.
On openHABian, Samba is already pre-installed and pre-configured. I’ll work with the openHABian settings and paths that it’s easy for openHABian users to adapt. Of course, this is working on any Linux system with Samba configured as well.
- Adjust the
smb.conf
file at/etc/samba
: Add the new lineopslock = false
to the[openHAB-logs]
section (this is needed to prevent caching on samba side). - Restart Samba with
systemctl restart smbd
- If not already done, install VSCode on your workstation PC
- If not already done, add the
[openHAB-logs]
network share to your workstation PC - Open VSCode. Press
Ctrl-Shift-X
to open the VSCode marketplace - Search & Install the Log Viewer extension
- Go to the
settings.json
of VSCode and add the following section:
The path may has to be adjusted depending on the hostname of your openHAB device and your workstation operating system. Please note that you have to escape each backslash with another backslash (so you have to write"logViewer.watch": [ { "title": "openhab.log", "pattern": "\\\\openhabiandevice\\openHAB-logs\\openhab.log" }, { "title": "events.log", "pattern": "\\\\openhabiandevice\\openHAB-logs\\events.log" } ]
\\
instead of\
). - Restart VSCode. The Log viewer icon should now appear on the side bar and you should be able to open the logs and watch them live. You can easily drag the tab to the side or on the bottom to view the logs while you are working e.g. on your items with the openHAB VSCode Extension
Feel free to share improvements on this approach in this thread. Or, of course, also share other approaches that you use to view logs live on your workstation apart from CLI-only approaches like tail -F
, would be interested in that