-
-
Notifications
You must be signed in to change notification settings - Fork 392
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
Split log configuration into system and user entries #516
Comments
@kaikreuzer Can you give any hint where to start looking to implement this feature? |
Not really. I guess 80% of the work for this issue is finding the right place and way how to implement it :-) We might think about moving from property files to XML files for the configuration as well (as it is also used in the docs now) - I somewhere read that XML includes should also work, so this might be another option for split files. One thing to also keep in mind is how to deal with logging configuration changes through the Karaf shell - the Hope this helps to get an idea about the issue and where to look at! |
I did some research. At the first try I got totally lost and gave up. A few days ago I coincidentally saw your comment in openhab/openhab-docs#476 containing the link to the new released documentation of Karaf logging. This manual is much better than the old version. Here are some facts I discovered so far. Now we have to put them together:
The first three points definitely makes sense and I am sure we can work out a solution for our problem statement. |
I don't think you need to add it to a piece of code. You can just set it using the JAVA_OPTS environment variable. I've used it before to suppress logging in Maven builds. :-) E.g. |
@wborn So would it be as simple as adding such a parameter to our setenv scripts? |
After a very very brief look I don't think Pax will pickup such logging configurations so it will probably not be visible/editable from the console. You'll be directly configuring Log4j2 with this and have to hope other logic leaves such configuration alone. |
There is an issue about log:get and log:set commands not properly working when using a log4j2.xml file (see KARAF-5354). So for proper functionality we would need to upgrade to Karaf 4.2.0 or newer. |
Hm, ok, so nothing for the 2.2 release then. Ok for me to live with the single file for the moment. |
I've made local build with OH 2.2.0 and Karaf 4.2.0.M1 and tested the implementation of using a log4j2.xml:
So in its current state you can not easily use it for splitting up configurations with XIncludes. It would be a nice replacement for properties files though! |
Is this still worth pursuing ? (or what @wborn mentioned in the last comment are show stoppers?) I have an idea about a proper implementation but I have some questions:
I can make some tests and propose a solution. |
I'd love whatever solution allows me to split up the log files according to bindings. |
@AngelosF Yes, definitely worth pursuing!
It seems as if everyone is using XML for log4j2, so we should do the same. |
FYI it is possible to have "per bundle" logging thanks to MDC/NDC - see configuration sample https://issues.apache.org/jira/browse/LOG4J2-2021. |
@AngelosF, did you make any progress on this in your tests? I started looking into this too but I don't want to waste my time if you've already discovered some limitations or problems. |
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 <[email protected]>
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 Signed-off-by: Wouter Born <[email protected]>
Currently, the logging configuration is stored in
userdata/etc/org.ops4j.pax.logging.cfg
. This file either gets overwritten by updates or not - but we do not have a chance to do adjustments in the system configuration without wiping any changes the user might have done.As we have moved to log4j2 now, there is chance to address this: log4j2 supports multiple configuration files.
It would therefore be ideal to have the system config stored in
runtime/etc
, while the user config could reside inconf
oruserdata/etc
(in case it is possible to edit the file e.g. through logging changes in the console).The text was updated successfully, but these errors were encountered: