[
https://issues.apache.org/jira/browse/LOG4J2-3450?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17513586#comment-17513586
]
Piotr Karwasz commented on LOG4J2-3450:
---------------------------------------
[~rgoers],
That is exactly my point: one Log4j2 configuration occurs around the start of
the application and one Log4j2 configuration occurs in
{{LoggingSystem#initialize}}. Both end up scanning the classpath and JVM's
working directory for certain files, which probably is not cheap
performance-wise.
Now, there can be a couple of cases:
# The first scan and the second scan find the same configuration file. In this
case Spring Boot should probably skip the reconfiguration, but there is nothing
we can do about it.
# The first scan and the second scan find different configuration files. This
can easily happen, since Spring Boot scans for a strict subset of configuration
filenames (e.g. {{log4j2-<contextName>.xml}} is not scanned for). In this case
the first configuration is overwritten with another one, but that's Spring
Boot's problem.
# The first scan does not find anything or better it finds
{{log4j2.springboot}} and instantiates a {{DefaultConfiguration}}. This is the
case I would like to address.
In the spirit of
[LOG4J2-2795|https://issues.apache.org/jira/browse/LOG4J2-2795] a developer
might decide he wants to cut some milliseconds from the startup time by setting
a new Log4j2 system property, let's say
{{log4j2.disableAutomaticConfiguration}}, to true. This setting would directly
use {{DefaultConfiguration}} instead of scanning the filesystem for
configuration files.
The problem you are citing, i.e. the fact that a {{DefaultConfiguration}} is
always created, even if we have another {{Configuration}} is interesting. I
will look into that.
> Add mechanism to disable Log4j2 automatic configuration
> -------------------------------------------------------
>
> Key: LOG4J2-3450
> URL: https://issues.apache.org/jira/browse/LOG4J2-3450
> Project: Log4j 2
> Issue Type: Task
> Reporter: Piotr Karwasz
> Assignee: Piotr Karwasz
> Priority: Minor
>
> Log4j2 automatic configuration is useful in most circumstances.
> However in specific environments it only adds some start-up time to the
> application. Such a specific environment is for example Spring Boot: Spring
> Boot reconfigures Log4j2 at a very early stage of its startup sequence, but
> *after* the automatic configuration. As a result Log4j2 is configured twice.
--
This message was sent by Atlassian Jira
(v8.20.1#820001)