You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by Gregg Donovan <gd...@etsy.com.INVALID> on 2019/07/30 17:38:31 UTC

20 second log4j2 configuration. How to fix?

Hello! We noticed when profiling our server startup that log4j2's
configuration process was taking over 20 seconds. From the YourKit profile
(see below) it appears to be from scanning the classpath for JARs that may
contain plugins. We have a lot of JARs, so this takes some time, I suppose.

Our configuration is fairly minimal. The StackdriverJsonLayout is a custom
Etsy plugin.

<?xml version="1.0" encoding="UTF-8" ?>
<Configuration status="error" dest="error" shutdownHook="disable"
packages="com.etsy.util,org.apache.logging.log4j.core.layout">
<Appenders><Console
name="console"><StackdriverJsonLayout/></Console></Appenders>
<Loggers><Root level="info"><AppenderRef ref="console" /></Root></Loggers>
</Configuration>

How can we minimize log4J2 configuration time? We're open to anything,
including using Java configuration. Minimizing configuration time trumps
all other concerns.

Thanks!

Gregg Donovan
Staff Software Engineer, Etsy.com


[image: Screenshot from 2019-07-29 15-59-31.png]

Re: 20 second log4j2 configuration. How to fix?

Posted by Gregg Donovan <gd...@etsy.com.INVALID>.
Thanks, Ralph! That's really helpful.

We use Bazel to build (bazel.build) and didn't have the PluginProcessor
configured. When I try adding PluginProcessor to Bazel, Bazel errors[1] due
to the PluginProcessor writing to stdout in 2.12.0
<https://github.com/apache/logging-log4j2/blob/log4j-2.12.0/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/processor/PluginProcessor.java>
.

I see that on master PluginProcessor uses javax.annotation.processing.Messenger
to send status and error messages. Would you be interested in backporting
that bit to a 2.x release?

Thanks!

Gregg


[1] -- "running annotation processors (PluginProcessor) failed: Worker
process returned an unparseable WorkResponse! Did you try to print
something to stdout? Workers aren't allowed to do this, as it breaks the
protocol between Bazel and the worker process."



On Tue, Jul 30, 2019 at 2:32 PM Ralph Goers <ra...@dslextreme.com>
wrote:

> Do you really need the packages attribute? If you have custom plugins they
> will normally be included in a file that is created when the annotation
> processor runs during compilation. If that file is present then package
> scanning is not required.
>
> Ralph
>
> > On Jul 30, 2019, at 10:38 AM, Gregg Donovan <gd...@etsy.com.INVALID>
> wrote:
> >
> > Hello! We noticed when profiling our server startup that log4j2's
> configuration process was taking over 20 seconds. From the YourKit profile
> (see below) it appears to be from scanning the classpath for JARs that may
> contain plugins. We have a lot of JARs, so this takes some time, I suppose.
> >
> > Our configuration is fairly minimal. The StackdriverJsonLayout is a
> custom Etsy plugin.
> >
> > <?xml version="1.0" encoding="UTF-8" ?>
> > <Configuration status="error" dest="error" shutdownHook="disable"
> packages="com.etsy.util,org.apache.logging.log4j.core.layout">
> > <Appenders><Console
> name="console"><StackdriverJsonLayout/></Console></Appenders>
> > <Loggers><Root level="info"><AppenderRef ref="console"
> /></Root></Loggers>
> > </Configuration>
> >
> > How can we minimize log4J2 configuration time? We're open to anything,
> including using Java configuration. Minimizing configuration time trumps
> all other concerns.
> >
> > Thanks!
> >
> > Gregg Donovan
> > Staff Software Engineer, Etsy.com
> >
> >
> >
>
>

Re: 20 second log4j2 configuration. How to fix?

Posted by Ralph Goers <ra...@dslextreme.com>.
Do you really need the packages attribute? If you have custom plugins they will normally be included in a file that is created when the annotation processor runs during compilation. If that file is present then package scanning is not required.

Ralph

> On Jul 30, 2019, at 10:38 AM, Gregg Donovan <gd...@etsy.com.INVALID> wrote:
> 
> Hello! We noticed when profiling our server startup that log4j2's configuration process was taking over 20 seconds. From the YourKit profile (see below) it appears to be from scanning the classpath for JARs that may contain plugins. We have a lot of JARs, so this takes some time, I suppose.
> 
> Our configuration is fairly minimal. The StackdriverJsonLayout is a custom Etsy plugin.
> 
> <?xml version="1.0" encoding="UTF-8" ?>
> <Configuration status="error" dest="error" shutdownHook="disable" packages="com.etsy.util,org.apache.logging.log4j.core.layout">
> <Appenders><Console name="console"><StackdriverJsonLayout/></Console></Appenders>
> <Loggers><Root level="info"><AppenderRef ref="console" /></Root></Loggers>
> </Configuration>
> 
> How can we minimize log4J2 configuration time? We're open to anything, including using Java configuration. Minimizing configuration time trumps all other concerns.
> 
> Thanks!
> 
> Gregg Donovan
> Staff Software Engineer, Etsy.com
> 
> 
>