logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Schudt, Christian" <Christian.Sch...@cgm.com>
Subject Issues found while migrating to 2.4.1
Date Wed, 02 Dec 2015 09:54:32 GMT
Hi,

I am migrating log4j 1 to version 2.4.1 and found a few issues, that I like to share.

1. The code found under "Programmatically Modifying the Current Configuration after Initialization"
does not compile:
https://logging.apache.org/log4j/2.x/manual/customconfig.html#AddingToCurrent


2. I've stumbled over the exact same problem as described here:
http://mail-archives.apache.org/mod_mbox/logging-log4j-user/201308.mbox/%3CCAAqLGLN9ai8teRZWcdVGszHZcQRErJ841qXT+RbVaufPQs0HWA@mail.gmail.com%3E

It would be nice if the API could protect against this error.
It's non-obvious that one *must* override "Configuration getConfiguration(final String name,
final URI configLocation)".


3. Programmatic configuration feels messy and it's not easy to get it working. I've tried
everything in https://logging.apache.org/log4j/2.x/manual/customconfig.html
In the end my only working solution is, that I *must* have a log4j2.xml file, because otherwise
log4j complains with "No log4j2 configuration file found. Using default configuration: logging
only errors to the console."
I then reconfigure log4j using "ctx.getConfiguration().getRootLogger().addAppender()" etc...

Reconfiguration using the Configurator.initialize() method didn't work as expected. Log entries
were still written as defined in log4j2.xml.


4. The API feels poorly conceived. E.g. RollingFileAppender.createAppender() takes way to
many parameters (15) for my taste and on top of that it uses String for nearly everything
(especially boolean), so that you have to pass a String "true" instead of simply true. The
same goes for DefaultRolloverStrategy.createStrategy() where you have to pass an integer "max"
as String.
I was hoping for some builder to create a RollingFileAppender, but the best I've found is
AppenderComponentBuilder, which doesn't build an Appender, but a Component and suffers from
the same problems (addAttribute methods are too generic).

Also should BuiltConfiguration not be BuildConfiguration? 

Should I post this on the dev list?

Thanks for your thoughts,
Christian




---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Mime
View raw message