Class AsyncLoggerContext

    • Constructor Detail

      • AsyncLoggerContext

        public AsyncLoggerContext​(java.lang.String name)
      • AsyncLoggerContext

        public AsyncLoggerContext​(java.lang.String name,
                                  java.lang.Object externalContext)
      • AsyncLoggerContext

        public AsyncLoggerContext​(java.lang.String name,
                                  java.lang.Object externalContext,
                                  java.net.URI configLocn)
      • AsyncLoggerContext

        public AsyncLoggerContext​(java.lang.String name,
                                  java.lang.Object externalContext,
                                  java.lang.String configLocn)
    • Method Detail

      • newInstance

        protected Logger newInstance​(LoggerContext ctx,
                                     java.lang.String name,
                                     MessageFactory messageFactory)
        Description copied from class: LoggerContext
        Callback to create a new logger.
        Overrides:
        newInstance in class LoggerContext
        Parameters:
        ctx - The LoggerContext this logger is associated with, never null.
        name - The logger name, never null.
        messageFactory - The message factory to be used, never null.
        Returns:
        A new logger instance.
      • setName

        public void setName​(java.lang.String name)
        Description copied from class: LoggerContext
        Sets the name.
        Overrides:
        setName in class LoggerContext
        Parameters:
        name - the new LoggerContext name
      • start

        public void start​(Configuration config)
        Description copied from class: LoggerContext
        Starts the context using a specific configuration.

        Warning: For backward compatibility, especially with Spring Boot, if the context is already started, this method will fall back to LoggerContext.reconfigure(Configuration). This behavior is maintained for legacy integrations and may change in future major versions. New code should not rely on this fallback.

        Overrides:
        start in class LoggerContext
        Parameters:
        config - The new Configuration to use for this context
      • maybeStartHelper

        private void maybeStartHelper​(Configuration config)
      • stop

        public boolean stop​(long timeout,
                            java.util.concurrent.TimeUnit timeUnit)
        Description copied from class: LoggerContext
        Blocks until all Log4j tasks have completed execution after a shutdown request and all appenders have shut down, or the timeout occurs, or the current thread is interrupted, whichever happens first.

        Not all appenders will honor this, it is a hint and not an absolute guarantee that the this method not block longer. Setting timeout too low increase the risk of losing outstanding log events not yet written to the final destination.

        Log4j can start threads to perform certain actions like file rollovers, calling this method with a positive timeout will block until the rollover thread is done.

        Specified by:
        stop in interface LifeCycle2
        Overrides:
        stop in class LoggerContext
        Parameters:
        timeout - the maximum time to wait, or 0 which mean that each apppender uses its default timeout, and don't wait for background tasks
        timeUnit - the time unit of the timeout argument
        Returns:
        true if the logger context terminated and false if the timeout elapsed before termination.
      • createRingBufferAdmin

        public RingBufferAdmin createRingBufferAdmin()
        Creates and returns a new RingBufferAdmin that instruments the ringbuffer of the AsyncLogger objects in this LoggerContext.
        Returns:
        a new RingBufferAdmin that instruments the ringbuffer
      • setUseThreadLocals

        public void setUseThreadLocals​(boolean useThreadLocals)
        Signals this context whether it is allowed to use ThreadLocal objects for efficiency.
        Parameters:
        useThreadLocals - whether this context is allowed to use ThreadLocal objects