Even though some people want log4j-core features on Android, I think
it's more important to at least get log4j-api to work properly on
Android. Sooner or later, some Android apps will depend on a Java
library which depends on log4j-api, and it would be good if that doesn't
break the app (at build time or at run time). This does not have to do
anything fancy, redirecting to Android LogCat would be enough for most apps.
I sometimes develop Android apps. I think that Android use cases for
RollingFileAppender or other advanced stuff in log4j-core (such as
filters) are quite rare. In most cases you either just want to redirect
to Android LogCat, or send the logs to some server over Internet.
Sending to some server is non-trivial given that mobile devices have
unreliable connections, but you probably want something Android specific
for that, the current log4j-core will not be a good fit by its own.
I think that any effort would be better spent on building a specific
Log4j implementation for Android, than making the regular log4j-core
work on Android.
On 2017-09-13 16:02, Ralph Goers wrote:
We are getting Jira issues about getting log4j to work in Android. At first,
all I thought was required was getting the API to function on top of Android’s
logging system. However, it seems that there are some who want to use the
RollingFileAppender or perhaps other appenders. The issue I have is that I am
pretty sure there are other things inside core that won’t work in Android,
which was why my first attempt was to just get the API working there.
Right now there are 8 open issues that mention Android. LOG4J2-1915,
LOG4J2-1920 LOG4J2-1921 all say that 2.8.2 doesn’t work, which was before the
Java 9 support was added. LOG4J2-2042 says 2.9 doesn’t work because of a
dependency on java.lang.management classes. LOG4J2-1920 says it has an error
because the ScriptEngineManager is not available.
I am not sure how to solve this. We could just say Android is not supported
although that would likely cause problems for a lot of people. We could only
support API integration, as I first tried to do, We could put in a bunch of
code to try to detect android and disable stuff that doesn’t work there, but
that is quite a bit of work and as far as I can tell none of the committers
work with Android. Finally, we could create a log4j-android that contains the
API combined with a minimal version of core.
Any thoughts on this?
Ralph