Getting daily error overview

@Oliver2 I implemented your proposal. A few questions:

  1. Why do you set useRawMsg to false? None of the default loggers have that setting?
  2. I assume vLog and vLogCount are resp. String and Number items? That seems to work for me. :slight_smile:
  3. I assume regex=".*(test|Test|vLog).*" is there to (obviously) exclude manual tests of all kinds, and updates to said items?
  4. What’s the trigger of your rule? I assume some kind of time based trigger? Every x minutes?
  5. How do you “clear” errors you’ve looked into? And/or would there be a way to not show entries that are older than y days? (Probably in the rule, then?)
  1. useRawMessage is required for regex filters which is only used for the new log file. It says to resolve parameters into text before applying the filter.
  2. correct
  3. correct
  4. correct
  5. currently I have a button which just deletes all entries after I had a look at the critical.log. I do not have proper access to my server at the moment. I‘ll post the script later. And for a different purpose I have created an item-list where you can swipe out entries for a json object, which solves your idea of deleting log entries one by one.

What’s x in your setup? Since you’ve worked with it, I assume you found out what’s practical :slight_smile:

3 Minutes.

Script for flushing log entries from log file:

var Paths = Java.type("java.nio.file.Paths");
var Files = Java.type("java.nio.file.Files");
var StandardOpenOption = Java.type("java.nio.file.StandardOpenOption");

var path = Paths.get("/var/log/openhab/critical.log");

if (Files.exists(path)) {
  Files.write(path, Java.to([], "byte[]"), StandardOpenOption.TRUNCATE_EXISTING, StandardOpenOption.WRITE);
}

items.vLog.postUpdate("[]");
items.vLogCount.postUpdate("0");

I think I’m missing the page open-popup-logdetails. No?

Are you stating that useRawMessage is required to work with regex filters in log4j2.xml? Or did I misunderstand? Because that’s not the case (as far as my experience goes).

No, it means the following:
If you have this line of code in your script:

console.warn("Test: {}", testVariable);

then regex will not work if you want to filter the string „Test: 3“, because the RawMessage is still „Test: {}“
useRawMsg=“false” applies resolving the variables which results in „Test: 3“ so that it can be filtered.
Note that this attribute is for filters only. And yes, if you want to apply filters for existing log files such as event or openhab you probably have to set this attribute, too.

ok. I have added the popup widget. Please see that I also added the missing part in the f7-list

1 Like

This really great application would definitely be worth a marketplace listing.

Unfortunately, I can’t get the pop-up to work; I have no idea where the problem lies.

My vLog item looks like this

[{"timestamp":"2025-12-29T14:26:37.867","level":"WARN","message":"Warning","threadName":"qtp808885953-5548","threadId":5548,"loggerName":"org.openhab.automation.jsscripting.rule.1a9bd9e8c4","loggerFQCN":"org.ops4j.pax.logging.slf4j.Slf4jLogger","bundle.id":"290","bundle.name":"org.graalvm.truffle.truffle-api","bundle.version":"25.0.1"},{"timestamp":"2025-12-29T14:26:37.871","level":"ERROR","message":"Error","threadName":"qtp808885953-5548","threadId":5548,"loggerName":"org.openhab.automation.jsscripting.rule.1a9bd9e8c4","loggerFQCN":"org.ops4j.pax.logging.slf4j.Slf4jLogger","bundle.id":"290","bundle.name":"org.graalvm.truffle.truffle-api","bundle.version":"25.0.1"}]

Your json object looks fine - otherwise you would see the same type of error in the overview widget.
Please have a look at the popup’s repeater. It needs to be exactly like this:

                - component: oh-list-item
                  config:
                    action: variable
                    actionVariable: logDetails
                    actionVariableValue: =JSON.stringify(loop.rLog_source[loop.rLog_idx])
                    badge: =loop.rLog.level
                    badgeColor: =(loop.rLog.level == "WARN")?"yellow":"red"
                    popupOpen: =".open-popup-logdetails"
                    subtitle: =loop.rLog.timestamp + ", " + loop.rLog.threadName
                    title: =loop.rLog.message

Please post your popup widget here so I can have a look

Hallo @Oliver2,

Thanks for the feedback.

The popoup is a 1:1 copy of here ( Getting daily error overview - #16 by Oliver2 ). I have checked this several times. The same with the repeater section. I am using openHAB 5.1.

popup yaml

uid: popup-logdetails
tags:
  - expanded-card-status
props:
  parameters: []
  parameterGroups: []
timestamp: Dec 29, 2025, 8:04:22 PM
component: f7-block
config:
  style:
    --f7-navbar-bg-color: transparent
    --f7-navbar-link-color: blue
    --f7-navbar-text-color: black
    -webkit-user-drag: none
    -webkit-user-select: none
    margin: 0px
    overflow-y: visible
    padding: 0px
    user-drag: none
    user-select: none
    width: 100%
    z-index: 9999
slots:
  default:
    - component: f7-navbar
      config:
        style:
          position: sticky
        title: Details
      slots:
        right:
          - component: oh-link
            config:
              action: popup
              iconColor: black
              iconF7: multiply_circle_fill
              iconSize: = 30px
              popupClose: =".open-popup-logdetails"
    - component: Label
      config:
        style:
          -webkit-user-select: all
          margin: 10px 0px 10px 23px
          padding: 0
          user-select: all
        text: =JSON.parse(vars.logDetails).message
    - component: f7-list
      config:
        bg-color: white
        inset: true
        mediaList: false
        noHairlinesBetween: false
        style:
          --f7-list-inset-border-radius: 8px
          margin-top: 0
      slots:
        default:
          - component: oh-repeater
            config:
              for: vLog
              fragment: true
              in:
                - vId: bundle.id
                  vLabel: Bundle ID
                - vId: bundle.name
                  vLabel: Bundle Name
                - vId: bundle.version
                  vLabel: Bundle Version
                - vId: threadName
                  vLabel: Thread Name
                - vId: threadId
                  vLabel: Thread ID
                - vId: loggerName
                  vLabel: Logger Name
                - vId: loggerFQCN
                  vLabel: Logger FQCN
                - vId: labels
                  vLabel: Thread Context Data (MDC)
                - vId: tags
                  vLabel: Thread Context Stack (NDC)
                - vId: marker
                  vLabel: Marker
                - vId: errorMessage
                  vLabel: Stack Trace - Message
                - vId: errorType
                  vLabel: Stack Trace - Klasse
                - vId: errorStacktrace
                  vLabel: Stack Trace
              sourceType: array
            slots:
              default:
                - component: f7-list-item
                  config: {}
                  slots:
                    inner-start:
                      - component: Label
                        config:
                          style:
                            font-size: 12px
                            width: 110px
                          text: =loop.vLog.vLabel
                      - component: Label
                        config:
                          style:
                            -webkit-user-select: all
                            font-size: 12px
                            text-align: left
                            user-select: all
                            width: 80%
                          text: =JSON.parse(vars.logDetails)[loop.vLog.vId]


    


I loaded your json string into my vLog item and it works just fine, which is good news as 50% of the solution is already working.

Could you also post your widget which shows the overview list?

Here is the code

config:
  label: Test
blocks:
  - component: oh-block
    config: {}
    slots:
      default:
        - component: oh-grid-row
          config: {}
          slots:
            default:
              - component: oh-grid-col
                config: {}
                slots:
                  default:
                    - component: oh-list-card
                      config:
                        accordionList: true
                      slots:
                        default:
                          - component: f7-list
                            config:
                              bg-color: white
                              class: -list
                              inset: true
                              mediaList: true
                              noHairlinesBetween: false
                            slots:
                              default:
                                - component: oh-repeater
                                  config:
                                    for: rLog
                                    fragment: true
                                    in: =JSON.parse(@@'vLog')
                                    sourceType: array
                                  slots:
                                    default:
                                      - component: oh-list-item
                                        config:
                                          action: variable
                                          actionVariable: logDetails
                                          actionVariableValue: =JSON.stringify(loop.rLog_source[loop.rLog_idx])
                                          badge: =loop.rLog.level
                                          badgeColor: =(loop.rLog.level == "WARN")?"yellow":"red"
                                          popupOpen: =".open-popup-logdetails"
                                          subtitle: =loop.rLog.timestamp + ", " + loop.rLog.threadName
                                          title: =loop.rLog.message
                          - component: f7-popup
                            config:
                              class: ="open-popup-logdetails"
                              closeByBackdropClick: true
                              closeOnEscape: true
                              style:
                                overflow-y: visible
                              swipeToClose: false
                            slots:
                              default:
                                - component: widget:popup-logdetails
                                  config: {}
masonry: []
grid: []
canvas: []

That’s weird. I couldn’t get it to work, too.
The problem is that variable logDetails stays undefined when clicking on an oh-list-item

action: variable
actionVariable: logDetails
actionVariableValue: =JSON.stringify(loop.rLog_source[loop.rLog_idx])

I assume the structure of your page (oh-list-card → f7-list) is somehow colliding.

Could you try the following structure?

  1. create an oh-cell on a page with this structure:
- component: oh-cell
  config: {}
  slots:
    default:
      - component: widget:expanded-card-status
        config: {}

  1. create a new personal widget expanded-card-status
component: f7-block
config: {}
slots:
  default:
    - component: f7-list
      => add the rest of the f7-list here

Hi,

First of all, I never saw any errors in event.log, AFAIK it only logs changes in state of items/things.

So you can focus on openhab.log I guess.

My approach is far less complex then what was debated here, but maybe someone cares for it, so here it is:

rule "LogReader"
when
    Channel 'logreader:reader:openhablog:newErrorEvent' triggered or
    Channel 'logreader:reader:openhablog:newWarningEvent' triggered
then
    if(DebounceLogs.state != ON){    
      smtp.sendMail("email@server.net", "openHAB Alert - New Error Occured", "Errors are in the log!")
      DebounceLogs.sendCommand(ON)}

This is done by utilizing logreader binding.

I use debounce on 20min, in case of some error flooding the log, my mailbox does not get flooded.

Of course, you can use other channels like telegram/whatsapp and the likes.

I didnt bother extracting the error message itself (even though I guess it could be done via the same binding), because my system can go for days/weeks without writing an error.

So when it happens, I have vpn, then ssh access from my android phone, and then alias command “ologs” tails the last X lines of openhab.log. I also have elogs alias for tailing event log.

So it takes me few seconds from receiving the email alert, to seeing the actual error.

at this point, I don’t remember if I created the alias commands or they come standard :slight_smile:

Just a side note, I did filter out some useless errors that regularly pop up from certain bindings (blocking them from writing to openhab.log file via log4j2.xml)

@Oliver2 I made a few changes and now it works for me too. The changes are on the page (action popup) and in the popup widget I work with parameters that are transferred when called. I think the problem has something to do with the JSON data transfer.

Is it possible to add a return after each entry in the critical.log so that the file is easier to read?


The popup code
uid: Widget_Logdetails_Popup
tags:
  - Logger
  - Popup
props:
  parameters:
    - description: The log details
      label: logDetails
      name: logDetails
      required: true
      type: TEXT
  parameterGroups: []
timestamp: Dec 30, 2025, 2:54:34 PM
component: f7-block
config:
  style:
    --f7-navbar-bg-color: transparent
    --f7-navbar-link-color: blue
    --f7-navbar-text-color: black
    -webkit-user-drag: none
    -webkit-user-select: none
    margin: 0px
    overflow-y: visible
    padding: 0px
    user-drag: none
    user-select: none
    width: 100%
    z-index: 9999
slots:
  default:
    - component: f7-navbar
      config:
        style:
          position: sticky
        title: Details
    - component: Label
      config:
        style:
          -webkit-user-select: all
          margin: 10px 0px 10px 23px
          padding: 0
          user-select: all
        text: =props.logDetails.message
    - component: f7-list
      config:
        bg-color: white
        inset: true
        mediaList: false
        noHairlinesBetween: false
        style:
          --f7-list-inset-border-radius: 8px
          margin-top: 0
      slots:
        default:
          - component: oh-repeater
            config:
              for: vLog
              fragment: true
              in:
                - vId: bundle.id
                  vLabel: Bundle ID
                - vId: bundle.name
                  vLabel: Bundle Name
                - vId: bundle.version
                  vLabel: Bundle Version
                - vId: threadName
                  vLabel: Thread Name
                - vId: threadId
                  vLabel: Thread ID
                - vId: loggerName
                  vLabel: Logger Name
                - vId: loggerFQCN
                  vLabel: Logger FQCN
                - vId: labels
                  vLabel: Thread Context Data (MDC)
                - vId: tags
                  vLabel: Thread Context Stack (NDC)
                - vId: marker
                  vLabel: Marker
                - vId: errorMessage
                  vLabel: Stack Trace - Message
                - vId: errorType
                  vLabel: Stack Trace - Klasse
                - vId: errorStacktrace
                  vLabel: Stack Trace
              sourceType: array
            slots:
              default:
                - component: f7-list-item
                  config: {}
                  slots:
                    inner-start:
                      - component: Label
                        config:
                          style:
                            font-size: 12px
                            width: 110px
                          text: =loop.vLog.vLabel
                      - component: Label
                        config:
                          style:
                            -webkit-user-select: all
                            font-size: 12px
                            text-align: left
                            user-select: all
                            width: 80%
                          text: =props.logDetails[loop.vLog.vId]

The page code
config:
  label: Display Errors
  sidebar: true
blocks:
  - component: oh-block
    config: {}
    slots:
      default:
        - component: oh-grid-row
          config: {}
          slots:
            default:
              - component: oh-grid-col
                config: {}
                slots:
                  default:
                    - component: oh-list-card
                      config:
                        accordionList: true
                      slots:
                        default:
                          - component: oh-list-item
                            config:
                              title: Warning/Error
                            slots:
                              accordion:
                                - component: f7-list
                                  config:
                                    bg-color: white
                                    class: -list
                                    inset: true
                                    mediaList: true
                                    noHairlinesBetween: false
                                  slots:
                                    default:
                                      - component: oh-repeater
                                        config:
                                          for: rLog
                                          fragment: true
                                          in: =JSON.parse(@@'vLog')
                                          sourceType: array
                                        slots:
                                          default:
                                            - component: oh-list-item
                                              config:
                                                action: popup
                                                actionModal: widget:Widget_Logdetails_Popup
                                                actionModalConfig:
                                                  logDetails: =loop.rLog_source[loop.rLog_idx]
                                                badge: =loop.rLog.level
                                                badgeColor: =(loop.rLog.level == "WARN")?"yellow":"red"
                                                subtitle: =loop.rLog.timestamp + ", " + loop.rLog.threadName
                                                title: =loop.rLog.message
masonry: []
grid: []
canvas: []

Yes, it is possible. Simply delete this attribute eventDelimiter="," from log4j2.xml.
But this means that you need to adjust your import script. that script will become more complex as JSON.parse() will not be working anymore.

Just a few notes as this line inside the repeater might have mislead you

for: vLog

This is a variable inside the repeater, it is not an item nor a string containing log details.
You can remove itemLog from actionModalConfig: and from props: parameters from your popup

Minor change: props: parameters logDetails is not of context item. But it works anyway as MainUI seems to be ignoring it.

There’s no popup when I click an entry… But maybe I put these components in another component which impedes the pop-up?

Would you mind sharing the complete yaml of your page?

@Oliver2 Thanks for the tips. I have edited my post.