Class LoggerContextFactory_Dummy

  • All Implemented Interfaces:
    org.apache.logging.log4j.spi.LoggerContextFactory

    public class LoggerContextFactory_Dummy
    extends java.lang.Object
    implements org.apache.logging.log4j.spi.LoggerContextFactory
    Author:
    Krasimir Topchiyski This factory can be used under Android in order to prevent the default Logging Factory to handle logging events. The default factory uses Java JMX API which is not presented under Android and the code throws ClassNotFoundError. You have to call LogManager.setFactory(new LoggerContextFactory_Dummy()); before any calls to Logger.getLogger(...). The best place for LogManager.setFactory method call is during your android.app.Application instance onCreate method execution.
    • Method Summary

      Modifier and Type Method Description
      org.apache.logging.log4j.spi.LoggerContext getContext​(java.lang.String fqcn, java.lang.ClassLoader loader, java.lang.Object externalContext, boolean currentContext)
      Creates a LoggerContext.
      org.apache.logging.log4j.spi.LoggerContext getContext​(java.lang.String fqcn, java.lang.ClassLoader loader, java.lang.Object externalContext, boolean currentContext, java.net.URI configLocation, java.lang.String name)
      Creates a LoggerContext.
      void removeContext​(org.apache.logging.log4j.spi.LoggerContext context)
      Removes knowledge of a LoggerContext.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • getContext

        public org.apache.logging.log4j.spi.LoggerContext getContext​(java.lang.String fqcn,
                                                                     java.lang.ClassLoader loader,
                                                                     java.lang.Object externalContext,
                                                                     boolean currentContext)
        Creates a LoggerContext.
        Specified by:
        getContext in interface org.apache.logging.log4j.spi.LoggerContextFactory
        Parameters:
        fqcn - The fully qualified class name of the caller.
        loader - The ClassLoader to use or null.
        externalContext - An external context (such as a ServletContext) to be associated with the LoggerContext.
        currentContext - If true returns the current Context, if false returns the Context appropriate for the caller if a more appropriate Context can be determined.
        Returns:
        The LoggerContext.
      • getContext

        public org.apache.logging.log4j.spi.LoggerContext getContext​(java.lang.String fqcn,
                                                                     java.lang.ClassLoader loader,
                                                                     java.lang.Object externalContext,
                                                                     boolean currentContext,
                                                                     java.net.URI configLocation,
                                                                     java.lang.String name)
        Creates a LoggerContext.
        Specified by:
        getContext in interface org.apache.logging.log4j.spi.LoggerContextFactory
        Parameters:
        fqcn - The fully qualified class name of the caller.
        loader - The ClassLoader to use or null.
        externalContext - An external context (such as a ServletContext) to be associated with the LoggerContext.
        currentContext - If true returns the current Context, if false returns the Context appropriate for the caller if a more appropriate Context can be determined.
        configLocation - The location of the configuration for the LoggerContext.
        name - The name of the context or null.
        Returns:
        The LoggerContext.
      • removeContext

        public void removeContext​(org.apache.logging.log4j.spi.LoggerContext context)
        Removes knowledge of a LoggerContext.
        Specified by:
        removeContext in interface org.apache.logging.log4j.spi.LoggerContextFactory
        Parameters:
        context - The context to remove.