Uploaded image for project: 'Log4j 2'
  1. Log4j 2
  2. LOG4J2-460

java.lang.ClassCastException: org.apache.logging.log4j.simple.SimpleLoggerContext cannot be cast to org.apache.logging.log4j.core.LoggerContext

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Blocker
    • Resolution: Duplicate
    • Affects Version/s: 2.0-beta9
    • Fix Version/s: None
    • Component/s: API
    • Labels:
    • Environment:

      Android

      Description

      I'm trying to integrate Log4j2 in Android but getting the following error message:

      java.lang.ClassCastException: org.apache.logging.log4j.simple.SimpleLoggerContext cannot be cast to org.apache.logging.log4j.core.LoggerContext

      Code:

      import org.apache.logging.log4j.Level;
      import org.apache.logging.log4j.LogManager;
      import org.apache.logging.log4j.core.Logger;
      import org.apache.logging.log4j.core.LoggerContext;
      import org.apache.logging.log4j.core.appender.SyslogAppender;
      
        LoggerContext context = (LoggerContext) LogManager.getContext();
        Logger root = context.getLogger("MainActivity");
        SyslogAppender appender = obtainAppender();
      
        if (!appender.isStarted()) 
          appender.start();
      
        root.addAppender(appender);
        root.setAdditive(false);
        root.setLevel(Level.DEBUG);
        root.debug("This is a test message");
      

        Attachments

        Issue Links

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              gauravk Gaurav Kapoor

              Dates

              • Created:
                Updated:
                Resolved:

                Issue deployment