You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by "JWT007 (via GitHub)" <gi...@apache.org> on 2025/02/03 02:18:41 UTC

[I] AbstractConfiguration clears Configuration name if some conditions are met (i.e. no defined loggers) (logging-log4j2)

JWT007 opened a new issue, #3431:
URL: https://github.com/apache/logging-log4j2/issues/3431

   Log4j 2.24.3 - AbstractConfiguration
   
   If I create a BuiltConfiguration that defines a Configuration 'name'  (i.e. "FooBar") and no loggers, the `AbstractConfigurat#doConfigure()` method calls the `setToDefault()` method for example if the following conditions are met:
   
   * no loggers are defined
   * no root logger is defined
   
   For example,
   
   ```
   if (!setLoggers) {
     LOGGER.warn("No Loggers were configured, using default. Is the Loggers element missing?");
     setToDefault();
     return;
   }
   ```
   
   The first thing the `setToDefault` method does is clear the given name and replace it with a default.
   
   ```
   protected void setToDefault() {
           // LOG4J2-1176 facilitate memory leak investigation
           setName(DefaultConfiguration.DEFAULT_NAME + "@" + Integer.toHexString(hashCode()));
          ...
   }
   ```
   
   It should however (IMHO) be a perfectly valid scenario to create a configuration with no content but with a custom name - specifically where I discovered this in testing.  But maybe I want to only define global filters and otherwise rely on default behaviour.
   
   In my opinion the name should only be set here if no name has yet been set.
   
   Generally it should be OK to set a configuration with no loggers and no root logger.  Consider a CompositeConfiguration named "FooBar" with an initially empty BuiltConfiguration.  Some runtime event might create appenders and loggers dynamically (ie. for a new service).  But it is no longer possible to lookup that configuration by name because a default has been applied.
   
   NOTE: The referenced bug/fix (https://issues.apache.org/jira/browse/LOG4J2-1176) doesn't seem to make any mention of the name being a problem.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] AbstractConfiguration clears Configuration name if some conditions are met (i.e. no defined loggers) (logging-log4j2)

Posted by "ppkarwasz (via GitHub)" <gi...@apache.org>.
ppkarwasz commented on issue #3431:
URL: https://github.com/apache/logging-log4j2/issues/3431#issuecomment-2651680020

   Thanks a lot!
   
   I will have some time next week to look at the open PRs.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] AbstractConfiguration clears Configuration name if some conditions are met (i.e. no defined loggers) [logging-log4j2]

Posted by "ppkarwasz (via GitHub)" <gi...@apache.org>.
ppkarwasz closed issue #3431: AbstractConfiguration clears Configuration name if some conditions are met (i.e. no defined loggers)
URL: https://github.com/apache/logging-log4j2/issues/3431


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] AbstractConfiguration clears Configuration name if some conditions are met (i.e. no defined loggers) (logging-log4j2)

Posted by "JWT007 (via GitHub)" <gi...@apache.org>.
JWT007 commented on issue #3431:
URL: https://github.com/apache/logging-log4j2/issues/3431#issuecomment-2651651227

   @ppkarwasz  - trying to take care of some of my many small bug reports - created a PR for this issue.
   
   Under the assumption that the above mentioned change for LOG4J-1176 was only added to ensure that a configuration gets a default name for testing the fix, I wrapped it so that the default name is only set if no name has already been set.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org