@@ -327,3 +327,55 @@ https://gradleup.com/shadow/[Gradle Shadow Plugin]:::
327
327
You need to use the
328
328
https://github.com/GradleUp/shadow/blob/main/src/main/groovy/com/github/jengelman/gradle/plugins/shadow/transformers/Log4j2PluginsCacheFileTransformer.groovy[`Log4j2PluginsCacheFileTransformer`].
329
329
====
330
+
331
+ [#android]
332
+ == Can I use Log4j with Android?
333
+
334
+ Of course, you can!
335
+ Since version `2.25.0` both the Log4j API and our three Log4j API implementations are tested for compatibility with the Android platform.
336
+
337
+ If you use
338
+ xref:manual/api.adoc[Log4j API]
339
+ in an Android project, you have four choices for the Log4j API implementation:
340
+
341
+ [#android-log4j-core]
342
+ Log4j Core::
343
+ +
344
+ Our
345
+ xref:manual/implementation.adoc[reference Log4j API implementation]
346
+ works on Android out-of-the-box.
347
+ However, due to the limitations of the Android platform, the following features will not work:
348
+ +
349
+ * The
350
+ xref:manual/configuration.adoc#xinclude[XInclude feature]
351
+ for XML configuration files will not work if you are using the standard Android XML parser.
352
+ You might need to add the
353
+ https://xerces.apache.org/[Xerces parser]
354
+ to use the feature.
355
+ * Due to the lack of Android support for multi-release JARs, some location-based features like the no-arg
356
+ link:javadoc/log4j-api/org/apache/logging/log4j/LogManager.html#getLogger()[`LogManager.getLogger()`]
357
+ method or
358
+ xref:manual/systemproperties.adoc#log4j2.contextSelector[`ClassLoaderContextSelector`]
359
+ (default on JRE) are not available.
360
+ You should use `BasicContextSelector` (default on Android) or `BasicAsyncLoggerContextSelector` instead.
361
+
362
+ [#android-jul]
363
+ JUL::
364
+ [#android-logback]
365
+ Logback::
366
+ +
367
+ Both our
368
+ xref:manual/installation.adoc#impl-jul[Log4j API-to-JUL]
369
+ and
370
+ xref:manual/installation.adoc#impl-logback[Log4j API-to-SLF4J]
371
+ bridges are tested for compatibility with Android.
372
+
373
+ [#android-native]
374
+ Log4j API-to-Android logging API bridge::
375
+ +
376
+ If you wish to bridge Log4j API to
377
+ https://developer.android.com/reference/android/util/Log[Android's native logging API]
378
+ directly, you can use the **third-party** `com.celeral:log4j2-android` artifact.
379
+ See the
380
+ https://github.com/Celeral/log4j2-android[`log4j2-android` project website]
381
+ for more information.
0 commit comments