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

Use XML instead of properties file for log4j2 configuration #1078

Merged
merged 1 commit into from
Feb 23, 2020

Conversation

wborn
Copy link
Member

@wborn wborn commented Feb 22, 2020

Note that Karaf processes the log4j2 configuration to add the sshd logger and this processing of XML elements is case sensitive.
It will throw exceptions if lower case element names are used or when the root logger is at the end of the list of loggers.

When new loggers are added, the XML configuration is serialized such that:

  • The <Configuration> element is added to the same line as the <?xml> element
  • Attributes are sorted so therefor the 'name' is at the end of the appender/logger lines

Related to #516


Including other configuration files still results in issues (see: #516 (comment)).

Note that Karaf processes the log4j2 configuration to add the sshd logger and this processing of XML elements is case sensitive.
It will throw exceptions if lower case element names are used or when the root logger is at the end of the list of loggers.

When new loggers are added, the XML configuration is serialized such that:
* The <Configuration> element is added to the same line as the <?xml> element
* Attributes are sorted so therefor the 'name' is at the end of the appender/logger lines

Related to openhab#516

Signed-off-by: Wouter Born <github@maindrain.net>
@wborn wborn requested a review from a team February 22, 2020 19:13
@kaikreuzer
Copy link
Member

I guess this will also require some documentation updates.
Could you add it to the backlog for the docs?

@wborn
Copy link
Member Author

wborn commented Feb 24, 2020

I've created openhab/openhab-docs#1163 for this.

Do you think we should also replace Logback with Log4j2 for OH3 development/tests? It might be easier to configure logging when users/contributors are already familiar with the log4j2 XML syntax when it is also used by the OH3 distro. Since log4j2 is more feature rich (complex) it may impact build times. Log4j2 probably also has more/bigger dependencies/artifacts. I do not know the exact reasons why Logback is currently used during development.

@wborn wborn deleted the loging-xml-config branch February 24, 2020 11:12
@openhab-bot
Copy link
Collaborator

This pull request has been mentioned on openHAB Community. There might be relevant details there:

https://community.openhab.org/t/logging-in-openhab-3/105784/3

@kaikreuzer
Copy link
Member

Logback is currently used because openHAB used to use logback from the beginning.
Yes, in general it makes a lot of sense to have the same logging in the IDE as in the distro.
I wouldn't really expect negative impact on build times by using a modern logging framework...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants