Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

log4j2.xml file corrupted after changing log settings #4612

Open
lpn-ch opened this issue Feb 21, 2025 · 0 comments
Open

log4j2.xml file corrupted after changing log settings #4612

lpn-ch opened this issue Feb 21, 2025 · 0 comments
Labels
bug An unexpected problem or unintended behavior of the Core

Comments

@lpn-ch
Copy link

lpn-ch commented Feb 21, 2025

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".

@lpn-ch lpn-ch added the bug An unexpected problem or unintended behavior of the Core label Feb 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An unexpected problem or unintended behavior of the Core
Projects
None yet
Development

No branches or pull requests

1 participant