Hi Gary,

On 19.11.2024 19:47, Gary D. Gregory wrote:
I don't want to not loose support for "root" (lower-case) in the Log4j 1 
configuration properties bridge since that's a documented feature in 1.x. I still have a 
product that uses 1.x style properties files, and converting converting our installed 
user's product files is not a task anyone wants to do (same for the files in our test 
suites).
I don't seem to understand, what does the Log4j 1 "root" logger have to
do with the Log4j Core 2 "root" logger configuration? Isn't the v1
configuration factory supposed to map the "root" logger to the "" logger?
Well, they use the exact same name: "root", but, I haven't looked at that code in a 
while. Are you saying that "root" in a 1.x will retain it's functionality? If yes, then 
good and we can close this part of the chat.

Sorry for the late answer. I looked deeper into the Log4j 1 implementation. If we are talking about the configuration of a logger (so a `LoggerConfig` object for Log4j 2 and a `Logger` object for Log4j 1):

* Log4j 1 has two "root" loggers: the root of the hierarchy that you configure with `log4j.rootLogger` and the configuration for a logger named "root" that you configure with `log4j.logger.root`.

* Log4j 2 has no support for the latter one: both `<Root>` and `<Logger name="root">` will configure the root of the `LoggerConfig` hierarchy.

* Logback also only supports one logger: the case insensitive constant "ROOT" will give you the root of the logger hierarchy.

I have never seen people naming a logger "root", so I think we should:

1. Use "ROOT" as alias for the root logger, not only in configuration files, but also in `Configurator.setLevel` and similar APIs.

2. Modify the implementation of `LoggerContext.getLogger()` so that the same logger is returned for "" and "root". In order for the logger to be usable, its `getName()` method should probably return "root", not the empty string.

What do you think?

Piotr

[1] https://logging.apache.org/log4j/1.x/apidocs/org/apache/log4j/Logger.html#getRootLogger()

Reply via email to