You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
implementations should be designed with asynchronous use in mind, and
99
99
either take a snapshot of their parameters at construction time, or
100
100
document their thread-safety characteristics.
101
+
101
102
* If your application is running in an environment where CPU resources
102
103
are scarce, like a machine with one CPU with a single core, starting
103
104
another thread is not likely to give better performance.
104
105
* If the _sustained rate_ at which your application is logging messages
105
106
is faster than the maximum sustained throughput of the underlying
106
107
appender, the queue will fill up and the application will end up logging
107
108
at the speed of the slowest appender. If this happens, consider
108
-
selecting a xref:manual/performance.adoc#whichAppender[faster appender], or
109
+
selecting an xref:manual/performance.adoc#whichAppender[faster appender], or
109
110
logging less. If neither of these is an option, you may get better
110
111
throughput and fewer latency spikes by logging synchronously.
111
112
@@ -116,7 +117,7 @@ NOTE: _Log4j-2.9 and higher require disruptor-3.3.4.jar or higher on the
116
117
classpath. Prior to Log4j-2.9, disruptor-3.0.0.jar or higher was
117
118
required._
118
119
119
-
This is simplest to configure and gives the best performance.
120
+
This is the simplest to configure and gives the best performance.
120
121
To make all loggers asynchronous, add the disruptor jar to the classpath and set the system property xref:manual/systemproperties.adoc#log4j2.contextSelector[log4j2.contextSelector] to `org.apache.logging.log4j.core.async.AsyncLoggerContextSelector` or `org.apache.logging.log4j.core.async.BasicAsyncLoggerContextSelector`.
121
122
122
123
By default, link:#Location[location] is not passed to the I/O thread by
@@ -190,17 +191,17 @@ and `log4j2.discardThreshold`].
190
191
== Mixing Synchronous and Asynchronous Loggers
191
192
192
193
NOTE: _Log4j-2.9 and higher require disruptor-3.3.4.jar or higher on the
193
-
classpath. Prior to Log4j-2.9, disruptor-3.0.0.jar or higher was
194
-
required. There is no need to set system property "Log4jContextSelector"
194
+
classpath. Before Log4j-2.9, disruptor-3.0.0.jar or higher was
195
+
required. There is no need to set the system property "Log4jContextSelector"
195
196
to any value._
196
197
197
198
Synchronous and asynchronous loggers can be combined in configuration.
198
199
This gives you more flexibility at the cost of a slight loss in
199
200
performance (compared to making all loggers asynchronous). Use the
200
-
`<asyncRoot>` or `<asyncLogger>` configuration elements to specify the
201
+
`<asyncRoot>` or `<asyncLogger>` configuration elements specify the
201
202
loggers that need to be asynchronous. A configuration can contain only
202
203
one root logger (either a `<root>` or an `<asyncRoot>` element), but
203
-
otherwise async and non-async loggers may be combined. For example, a
204
+
otherwise, async and non-async loggers may be combined. For example, a
204
205
configuration file containing `<asyncLogger>` elements can also contain
205
206
`<root>` and `<logger>` elements for the synchronous loggers.
206
207
@@ -308,7 +309,7 @@ public interface AsyncWaitStrategyFactory {
308
309
The specified class must also have a public no-argument constructor;
309
310
Log4j will instantiate an instance of the specified factory class and use this factory to create the WaitStrategy used by all Async Loggers.
310
311
311
-
WaitStrategy-related system properties are ignored if a `AsyncWaitStrategyFactory` is configured.
312
+
WaitStrategy-related system properties are ignored if an `AsyncWaitStrategyFactory` is configured.
312
313
313
314
314
315
[#Location]
@@ -338,7 +339,7 @@ logging with location is 30-100 times slower than without location. For
338
339
this reason, asynchronous loggers and asynchronous appenders do not
339
340
include location information by default.
340
341
341
-
You can override the default behaviour in your logger or asynchronous
342
+
You can override the default behavior in your logger or asynchronous
342
343
appender configuration by specifying `includeLocation="true"`.
343
344
344
345
[#Performance]
@@ -378,10 +379,10 @@ higher throughput than sync loggers.]
378
379
379
380
=== Asynchronous Throughput Comparison with Other Logging Packages
380
381
381
-
We also compared peak throughput of asynchronous loggers to the
382
+
We also compared the peak throughput of asynchronous loggers to the
382
383
synchronous loggers and asynchronous appenders available in other
383
384
logging packages, specifically log4j-1.2.17 and logback-1.0.10, with
384
-
similar results. For asynchronous appenders, total logging throughput of
385
+
similar results. For asynchronous appenders, the total logging throughput of
385
386
all threads together remains roughly constant when adding more threads.
386
387
Asynchronous loggers make more effective use of the multiple cores
387
388
available on the machine in multi-threaded scenarios.
@@ -457,14 +458,13 @@ threads
457
458
458
459
This section has been rewritten with the Log4j 2.6 release. The
459
460
previous version only reported _service time_ instead of _response
460
-
time_. See the xref:manual/performance.adoc#responseTime[response time] side
461
-
bar on the performance page on why this is too optimistic. Furthermore
462
-
the previous version reported average latency, which does not make sense
461
+
time_. See the xref:manual/performance.adoc#responseTime[response time] sidebar on the performance page on why this is too optimistic.
462
+
Furthermore, the previous version reported average latency, which does not make sense
463
463
since latency is not a normal distribution. Finally, the previous
464
464
version of this section only reported the maximum latency of up to
465
465
99.99% of the measurements, which does not tell you how bad the worst
466
466
0.01% were. This is unfortunate because often the "outliers" are all
467
-
that matter when it comes to response time. From this release we will
467
+
that matter when it comes to response time. From this release, we will
468
468
try to do better and report response time latency across the full range
469
469
of percentages, including all the outliers. Our thanks to Gil Tene for
470
470
his http://www.infoq.com/presentations/latency-response-time[How NOT to
@@ -473,11 +473,11 @@ the "Oh s#@t!" presentation.)
473
473
474
474
xref:manual/performance.adoc#responseTime[Response time] is how long it
475
475
takes to log a message under a certain load. What is often reported as
476
-
latency is actually _service time_: how long it took to perform the
477
-
operation. This hides the fact that a single spike in service time adds
478
-
queueing delay for many of the subsequent operations. Service time is
476
+
latency is _service time_: how long it took to operate.
477
+
This hides the fact that a single spike in service time adds
478
+
a queueing delay for many of the subsequent operations. Service time is
479
479
easy to measure (and often looks good on paper) but is irrelevant for
480
-
users since it omits the time spent waiting for service. For this reason
480
+
users since it omits the time spent waiting for service. For this reason,
481
481
we report response time: service time plus wait time.
482
482
483
483
The response time test results below were all derived from running the
@@ -494,9 +494,9 @@ wait strategy reduces some jitter.)
0 commit comments