[ 
https://issues.apache.org/jira/browse/LOG4J2-951?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Joe Merten updated LOG4J2-951:
------------------------------
    Description: 
[This|https://github.com/Joe-Merten/Mpjoe/tree/b8564c852e0955c7b9342ad928957505edd4b88d/Android]
 small Android project compiles using {{mvn clean install}}.

It includes something like

{code:java}
    import org.apache.logging.log4j.LogManager;
    import org.apache.logging.log4j.Logger;
    // ...
    logger.info("=== Initialized ===");
{code}

For configuring log4j2, I use a programmatically approch (see 
[Log4jConfigure.java|https://github.com/Joe-Merten/Mpjoe/blob/b8564c852e0955c7b9342ad928957505edd4b88d/Common/src/main/java/de/jme/toolbox/logging/Log4jConfigure.java])
 to 
prevent the log4j2.xml Android issue as described in LOG4J2-721 and LOG4J2-728.

But I didn't see my logging output on logcat.
Seems that I need something like a {{LogcatAppender}} but couldn't find hints 
how to do that.

I found [this|https://code.google.com/p/android-logging-log4j] project but it 
has no commits over the last 2 years and so it seems that it not fits to log4j2.

Seeing this output in logcat:
{quote}
ERROR StatusLogger Log4j2 could not find a logging implementation. Please add 
log4j-core to the classpath. Using SimpleLogger to log to the console...
{quote}

A bit further investigation:

* logging with {{logger.fatal()}} and {{logger.error()}} gave me output to 
logcat, but both with {{Level = Warning}} and {{Tag = System.err}}
* all other {{logger.warn()}} ... {{logger.trace()}} were suppressed

When checking the system property {{java.class.path}}, it returns {{"."}}, but 
this seems a normal circumstance (as described on 
[developer.android.com|http://developer.android.com]).

So falling back to the key questions: How to configure log4j2 properly to 
produce correct Android logcat output?

* want to have the loglevel placed correctly
* using the classname for the logcat tag seems a nice idea

Could anybory help?


  was:
[This|https://github.com/Joe-Merten/Mpjoe/tree/master/Android] small Android 
project compiles using {{mvn clean install}}.

It includes something like

{code:java}
    import org.apache.logging.log4j.LogManager;
    import org.apache.logging.log4j.Logger;
    // ...
    logger.info("=== Initialized ===");
{code}

But I didn't see my logging output on logcat.
Seems that I need something like a {{LogcatAppender}} but couldn't find hints 
how to do that.

I found [this|https://code.google.com/p/android-logging-log4j] project but it 
has no commits over the last 2 years and so it seems that it not fits to log4j2.

Seeing this output in logcat:
{quote}
ERROR StatusLogger Log4j2 could not find a logging implementation. Please add 
log4j-core to the classpath. Using SimpleLogger to log to the console...
{quote}

A bit further investigation:

* as log as I'm unable to load log4j2.xml, log4j uses the SimpleLogger
* logging with {{logger.fatal()}} and {{logger.error()}} gave me output to 
logcat, but both with {{Level = Warning}} and {{Tag = System.err}}
* all other {{logger.warn()}} ... {{logger.trace()}} were suppressed

So falling back to the key questions: How to configure log4j2 properly to 
produce correct Android logcat output?

* want to have the loglevel placed correctly
* using the classname for the logcat tag seems a nice idea

(I'd also tried out 
[this|http://stackoverflow.com/questions/28235021/log4j2-on-android] 
(log4j2.xml content into a String) but without success.)

Could anybory help?



> How to use log4j2 with Android (Logcat)?
> ----------------------------------------
>
>                 Key: LOG4J2-951
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-951
>             Project: Log4j 2
>          Issue Type: Question
>          Components: Appenders
>    Affects Versions: 2.1
>         Environment: Android
>            Reporter: Joe Merten
>              Labels: Android, maven
>
> [This|https://github.com/Joe-Merten/Mpjoe/tree/b8564c852e0955c7b9342ad928957505edd4b88d/Android]
>  small Android project compiles using {{mvn clean install}}.
> It includes something like
> {code:java}
>     import org.apache.logging.log4j.LogManager;
>     import org.apache.logging.log4j.Logger;
>     // ...
>     logger.info("=== Initialized ===");
> {code}
> For configuring log4j2, I use a programmatically approch (see 
> [Log4jConfigure.java|https://github.com/Joe-Merten/Mpjoe/blob/b8564c852e0955c7b9342ad928957505edd4b88d/Common/src/main/java/de/jme/toolbox/logging/Log4jConfigure.java])
>  to 
> prevent the log4j2.xml Android issue as described in LOG4J2-721 and 
> LOG4J2-728.
> But I didn't see my logging output on logcat.
> Seems that I need something like a {{LogcatAppender}} but couldn't find hints 
> how to do that.
> I found [this|https://code.google.com/p/android-logging-log4j] project but it 
> has no commits over the last 2 years and so it seems that it not fits to 
> log4j2.
> Seeing this output in logcat:
> {quote}
> ERROR StatusLogger Log4j2 could not find a logging implementation. Please add 
> log4j-core to the classpath. Using SimpleLogger to log to the console...
> {quote}
> A bit further investigation:
> * logging with {{logger.fatal()}} and {{logger.error()}} gave me output to 
> logcat, but both with {{Level = Warning}} and {{Tag = System.err}}
> * all other {{logger.warn()}} ... {{logger.trace()}} were suppressed
> When checking the system property {{java.class.path}}, it returns {{"."}}, 
> but this seems a normal circumstance (as described on 
> [developer.android.com|http://developer.android.com]).
> So falling back to the key questions: How to configure log4j2 properly to 
> produce correct Android logcat output?
> * want to have the loglevel placed correctly
> * using the classname for the logcat tag seems a nice idea
> Could anybory help?



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscr...@logging.apache.org
For additional commands, e-mail: log4j-dev-h...@logging.apache.org

Reply via email to