Logging from commandline possible?

  • Platform information:
    • Hardware: Raspberry Pi 3 Model B
    • OS: openhabian 32 v1.6.5
    • openHAB version: 3.0.1
  • Issue of the topic:

Is it possible to create openhab log entries from commandline or via REST-API?
I use a python script to fetch data from a bluetooth device. If there is an error during communication I will create an log entry in openhab.log.


Create a String Item ‘myloggingitem’ and update it via REST.

1 Like

A string item works. Thanks for sharing this tip.

But it’s not a real logging, it’s only through the bypass over an item. Better than no possibility at all, but I miss the possibility of the log level, so INFO, WARN, ERROR and so on.

No chance to write an entry directly into the openhab.log?

Well,it’s pretty unlikely. Why would any application allow some random external script to write in its log?

You could write a rule that listens for updates to the interim Item, then rewrites the message using logInfi/logWarn/logError() as determined by some analysis.

Maybe if you reveal your actual purpose here?

OK, that’s an argument.

And that changed my point of view. I now write my own log file (e.g. others.log) in /var/log/openhab/. After changing the frontail.services the entries are now also displayed via http://openhab-ip:9001. If I format them like the others the highlighting also works.