Howto: Watch openHAB logs remote & live with Samba & VSCode (works on openHABian)

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.

  1. Adjust the smb.conf file at /etc/samba: Add the new line opslock = false to the [openHAB-logs] section (this is needed to prevent caching on samba side).
  2. Restart Samba with systemctl restart smbd
  3. If not already done, install VSCode on your workstation PC
  4. If not already done, add the [openHAB-logs] network share to your workstation PC
  5. Open VSCode. Press Ctrl-Shift-X to open the VSCode marketplace
  6. Search & Install the Log Viewer extension
  7. Go to the settings.json of VSCode and add the following section:
    "": [
            "title": "openhab.log",
            "pattern": "\\\\openhabiandevice\\openHAB-logs\\openhab.log"
            "title": "events.log",
            "pattern": "\\\\openhabiandevice\\openHAB-logs\\events.log"
    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 \\ instead of \).
  8. 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 :slight_smile:


Just curious. Why use VS Code & SAMBA instead of VS Code with its built in SSH capabilities?

I like this one more because it allows to make use of VSCode’s full feature set (scroll preview, searching within the logs, Syntax highlighting, …). Also, you don’t have to connect via SSH on every new session. Of course, there will be ways to configure most of that for the SSH way as well.

This guide shows one approach of many possible without claiming it’s the best one. Feel free to share the one that you use and how it compares to this one :slight_smile:

Really nice tutorial, thanks. :slight_smile:

Maybe we yould use LogViewer as a dependency in openHAB vscode extension to make this available per default when installing the openHAB extension.

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.