This i a question ask a few times but i thought after the new Log Viewer (4.3 and newer) capability things may have changed so i would ask anyway
There are many times we need to store events and retrieve them into the UI and ise for other uses, for example the status on solar inverters.
As i see it there are 3 options
1)we send log messages to the standard openHAB log but it is not great for long term storage or retrieval.
2)Writing the events to a system file is great for long term but becomes clumsy to display in the Main UI.
Storing in a string item but this introduces difficulties in parsing and searching.
Myquestion is there any thought on the capability to use the new Log Viewer to read a custom log file, this would provide a really interesting option because its searchable, provides filtering and also an export and download capability. Additionally with logs that are not very active the last 100 events would always be there.
That’s currently not possible at all, because the log viewer doesn’t work with log files at all. Frontail, the “old” log viewer, works with files, and you can configure it to display content from whatever files you want. The MainUI log viewer on the other hand, works with “events” from the logging system, and has no file-reading capability at all.
The last 100 events aren’t kept “per log file”, it’s the last 100 events that happened on the system as a whole. It’s a very small cache, practically useless in many situations, but it’s the default size OSGi/Karaf caches. You can configure the size somewhere, I don’t remember where now, but it will eat more RAM as a consequence. But, if you apply filtering, you will only filter among those 100 events, so you’ll get “fewer events back in time”.
The canonical approach to what you need is to use persistence, assuming you want this information in a rule somehow. If you just want it in a log to personally look at or analyze with a third party tool, toy can create a custom logger config.
You can create custom loggers and appenders in $OH_USERDATA/etc/log4j2.xml. The appender defines the log file name and how rollover happens, format of the log lines and such. The logger defines which loggers log to which appender. So you just need to define a custom appender and tell it which logger to output to.
Modifying the logging in this way is not supported in MainUI and I wouldn’t hold my breath on someone taking that on. It’ll be a lot of work for some pretty niche use cases.
You can see examples for how to configure a separate log file in Many of the add-on readmes including zeave and zigbee and there’s are tons of examples in posts on the forum.
But this separate file will not be visible nor have any impact on what you see in the MainUI logger.