Skip to content

log4j2.xml file corrupted after changing log settings #4612

Open
@lpn-ch

Description

@lpn-ch

OH 4.3.2 running in a docker

After trying to change multiple log settings at once in the MQTT binding, the log4j2.xml file got corrupted.

Here are the settings I tried to change one shot:

Image

After saving and going to check the log viewer, I only had this message and it only appeared when refreshing the web page:

Image

After searching on the web it pointed to a possible log4j2.xml corrupted file and that's exactly what it was. Here is the end of the file, it is not a typo:

                <!-- Added by Karaf to prevent debug logging loops, see -->
                <!-- https://issues.apache.org/jira/browse/KARAF-5559 -->
                <Logger level="WARN" name="org.apache.sshd"/>
                <Logger level="INFO" name="org.openhab.persistence.influxdb"/>
                <Logger level="INFO" name="org.openhab.io.homekit"/>
                <Logger level="TRACE" name="org.openhab.binding.mqtt.generic"/>
        </Loggers>

</Configuration>ation>

After correcting the closing tag everything was working fine again.

I tried to reproduce the issue but I did not get it the second time, but I did see that you cannot actually change multiple log settings at once, it only changes one at a time, so this is also a bug since a user, like me, would think after saving and exiting that all changes would be enabled, but no. You actually see it above, only "org.openhab.binding.mqtt.generic" was changed. This issue is maybe linked to the corrupted file.

EDIT:
I managed to reproduce the issue by taking a file I did not edit myself from a backup. There is a difference between the original file and after I edit the file, take a look when I do a cat of the file that becomes corrupted (before it gets corrupted):

Image

And the file after I edit and fix it, nano inserts a newline after the last line which cannot be removed:

Image

It seems that the original file does not have a newline char after the last tag and that seems to cause the broken file issue.

EDIT2:
There is another issue, when you go in the MQTT settings to change the log settings and you don't change any log settings and go back without saving, it says "Changes have not been saved".

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugAn unexpected problem or unintended behavior of the Core

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions