Class LogRecorder

  • All Implemented Interfaces:
    java.io.Serializable, org.apache.logging.log4j.Logger, org.apache.logging.log4j.spi.ExtendedLogger, org.apache.logging.log4j.spi.LocationAwareLogger

    public final class LogRecorder
    extends org.apache.logging.log4j.spi.AbstractLogger
    implements org.apache.logging.log4j.Logger
    The Class LogRecorder can only record log messages. It ignores the level.

    This class can be useful for testing if you want to check if a specific message appears in the log.

    Since:
    09.10.2008
    Version:
    $Revision: 1.16 $
    Author:
    oliver
    See Also:
    Serialized Form
    • Field Summary

      • Fields inherited from class org.apache.logging.log4j.spi.AbstractLogger

        CATCHING_MARKER, DEFAULT_FLOW_MESSAGE_FACTORY_CLASS, DEFAULT_MESSAGE_FACTORY_CLASS, ENTRY_MARKER, EXCEPTION_MARKER, EXIT_MARKER, FLOW_MARKER, logBuilder, name, THROWING_MARKER
    • Constructor Summary

      Constructors 
      Constructor Description
      LogRecorder()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      org.apache.logging.log4j.Level getLevel()  
      int getNumberOfRecords()
      Gets the number of records.
      java.lang.String getRecord()
      Gets the record.
      java.lang.String getText()
      Gets the text.
      boolean isEnabled​(org.apache.logging.log4j.Level level, org.apache.logging.log4j.Marker marker, java.lang.CharSequence message, java.lang.Throwable t)  
      boolean isEnabled​(org.apache.logging.log4j.Level level, org.apache.logging.log4j.Marker marker, java.lang.Object message, java.lang.Throwable t)  
      boolean isEnabled​(org.apache.logging.log4j.Level level, org.apache.logging.log4j.Marker marker, java.lang.String message)  
      boolean isEnabled​(org.apache.logging.log4j.Level level, org.apache.logging.log4j.Marker marker, java.lang.String message, java.lang.Object p0)  
      boolean isEnabled​(org.apache.logging.log4j.Level level, org.apache.logging.log4j.Marker marker, java.lang.String message, java.lang.Object... params)  
      boolean isEnabled​(org.apache.logging.log4j.Level level, org.apache.logging.log4j.Marker marker, java.lang.String message, java.lang.Object p0, java.lang.Object p1)  
      boolean isEnabled​(org.apache.logging.log4j.Level level, org.apache.logging.log4j.Marker marker, java.lang.String message, java.lang.Object p0, java.lang.Object p1, java.lang.Object p2)  
      boolean isEnabled​(org.apache.logging.log4j.Level level, org.apache.logging.log4j.Marker marker, java.lang.String message, java.lang.Object p0, java.lang.Object p1, java.lang.Object p2, java.lang.Object p3)  
      boolean isEnabled​(org.apache.logging.log4j.Level level, org.apache.logging.log4j.Marker marker, java.lang.String message, java.lang.Object p0, java.lang.Object p1, java.lang.Object p2, java.lang.Object p3, java.lang.Object p4)  
      boolean isEnabled​(org.apache.logging.log4j.Level level, org.apache.logging.log4j.Marker marker, java.lang.String message, java.lang.Object p0, java.lang.Object p1, java.lang.Object p2, java.lang.Object p3, java.lang.Object p4, java.lang.Object p5)  
      boolean isEnabled​(org.apache.logging.log4j.Level level, org.apache.logging.log4j.Marker marker, java.lang.String message, java.lang.Object p0, java.lang.Object p1, java.lang.Object p2, java.lang.Object p3, java.lang.Object p4, java.lang.Object p5, java.lang.Object p6)  
      boolean isEnabled​(org.apache.logging.log4j.Level level, org.apache.logging.log4j.Marker marker, java.lang.String message, java.lang.Object p0, java.lang.Object p1, java.lang.Object p2, java.lang.Object p3, java.lang.Object p4, java.lang.Object p5, java.lang.Object p6, java.lang.Object p7)  
      boolean isEnabled​(org.apache.logging.log4j.Level level, org.apache.logging.log4j.Marker marker, java.lang.String message, java.lang.Object p0, java.lang.Object p1, java.lang.Object p2, java.lang.Object p3, java.lang.Object p4, java.lang.Object p5, java.lang.Object p6, java.lang.Object p7, java.lang.Object p8)  
      boolean isEnabled​(org.apache.logging.log4j.Level level, org.apache.logging.log4j.Marker marker, java.lang.String message, java.lang.Object p0, java.lang.Object p1, java.lang.Object p2, java.lang.Object p3, java.lang.Object p4, java.lang.Object p5, java.lang.Object p6, java.lang.Object p7, java.lang.Object p8, java.lang.Object p9)  
      boolean isEnabled​(org.apache.logging.log4j.Level level, org.apache.logging.log4j.Marker marker, java.lang.String message, java.lang.Throwable t)
      This check returns true for all levels.
      boolean isEnabled​(org.apache.logging.log4j.Level level, org.apache.logging.log4j.Marker marker, org.apache.logging.log4j.message.Message message, java.lang.Throwable t)  
      void logMessage​(java.lang.String fqcn, org.apache.logging.log4j.Level level, org.apache.logging.log4j.Marker marker, org.apache.logging.log4j.message.Message message, java.lang.Throwable t)
      The message is logged and recorded here.
      java.lang.String toString()
      To string.
      • Methods inherited from class org.apache.logging.log4j.spi.AbstractLogger

        always, atDebug, atError, atFatal, atInfo, atLevel, atTrace, atWarn, catching, catching, catching, catchingMsg, checkMessageFactory, debug, debug, debug, debug, debug, debug, debug, debug, debug, debug, debug, debug, debug, debug, debug, debug, debug, debug, debug, debug, debug, debug, debug, debug, debug, debug, debug, debug, debug, debug, debug, debug, debug, debug, debug, debug, debug, debug, debug, debug, debug, debug, debug, debug, debug, debug, debug, debug, enter, enter, enter, enter, enter, entry, entry, entry, entryMsg, entryMsg, entryMsg, error, error, error, error, error, error, error, error, error, error, error, error, error, error, error, error, error, error, error, error, error, error, error, error, error, error, error, error, error, error, error, error, error, error, error, error, error, error, error, error, error, error, error, error, error, error, error, error, exit, exit, exit, exit, exitMsg, fatal, fatal, fatal, fatal, fatal, fatal, fatal, fatal, fatal, fatal, fatal, fatal, fatal, fatal, fatal, fatal, fatal, fatal, fatal, fatal, fatal, fatal, fatal, fatal, fatal, fatal, fatal, fatal, fatal, fatal, fatal, fatal, fatal, fatal, fatal, fatal, fatal, fatal, fatal, fatal, fatal, fatal, fatal, fatal, fatal, fatal, fatal, fatal, getMessageFactory, getName, getRecursionDepth, info, info, info, info, info, info, info, info, info, info, info, info, info, info, info, info, info, info, info, info, info, info, info, info, info, info, info, info, info, info, info, info, info, info, info, info, info, info, info, info, info, info, info, info, info, info, info, info, isDebugEnabled, isDebugEnabled, isEnabled, isEnabled, isErrorEnabled, isErrorEnabled, isFatalEnabled, isFatalEnabled, isInfoEnabled, isInfoEnabled, isTraceEnabled, isTraceEnabled, isWarnEnabled, isWarnEnabled, log, log, log, log, log, log, log, log, log, log, log, log, log, log, log, log, log, log, log, log, log, log, log, log, log, log, log, log, log, log, log, log, log, log, log, log, log, log, log, log, log, log, log, log, log, log, log, log, log, logIfEnabled, logIfEnabled, logIfEnabled, logIfEnabled, logIfEnabled, logIfEnabled, logIfEnabled, logIfEnabled, logIfEnabled, logIfEnabled, logIfEnabled, logIfEnabled, logIfEnabled, logIfEnabled, logIfEnabled, logIfEnabled, logIfEnabled, logIfEnabled, logIfEnabled, logMessage, logMessage, logMessage, logMessage, logMessage, logMessage, logMessage, logMessage, logMessage, logMessage, logMessage, logMessage, logMessage, logMessage, logMessage, logMessage, logMessage, logMessage, logMessage, printf, printf, requiresLocation, throwing, throwing, throwing, throwingMsg, trace, trace, trace, trace, trace, trace, trace, trace, trace, trace, trace, trace, trace, trace, trace, trace, trace, trace, trace, trace, trace, trace, trace, trace, trace, trace, trace, trace, trace, trace, trace, trace, trace, trace, trace, trace, trace, trace, trace, trace, trace, trace, trace, trace, trace, trace, trace, trace, traceEntry, traceEntry, traceEntry, traceEntry, traceEntry, traceExit, traceExit, traceExit, traceExit, traceExit, traceExit, warn, warn, warn, warn, warn, warn, warn, warn, warn, warn, warn, warn, warn, warn, warn, warn, warn, warn, warn, warn, warn, warn, warn, warn, warn, warn, warn, warn, warn, warn, warn, warn, warn, warn, warn, warn, warn, warn, warn, warn, warn, warn, warn, warn, warn, warn, warn, warn
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface org.apache.logging.log4j.Logger

        always, atDebug, atError, atFatal, atInfo, atLevel, atTrace, atWarn, catching, catching, debug, debug, debug, debug, debug, debug, debug, debug, debug, debug, debug, debug, debug, debug, debug, debug, debug, debug, debug, debug, debug, debug, debug, debug, debug, debug, debug, debug, debug, debug, debug, debug, debug, debug, debug, debug, debug, debug, debug, debug, debug, debug, debug, debug, debug, debug, debug, debug, entry, entry, error, error, error, error, error, error, error, error, error, error, error, error, error, error, error, error, error, error, error, error, error, error, error, error, error, error, error, error, error, error, error, error, error, error, error, error, error, error, error, error, error, error, error, error, error, error, error, error, exit, exit, fatal, fatal, fatal, fatal, fatal, fatal, fatal, fatal, fatal, fatal, fatal, fatal, fatal, fatal, fatal, fatal, fatal, fatal, fatal, fatal, fatal, fatal, fatal, fatal, fatal, fatal, fatal, fatal, fatal, fatal, fatal, fatal, fatal, fatal, fatal, fatal, fatal, fatal, fatal, fatal, fatal, fatal, fatal, fatal, fatal, fatal, fatal, fatal, getMessageFactory, getName, info, info, info, info, info, info, info, info, info, info, info, info, info, info, info, info, info, info, info, info, info, info, info, info, info, info, info, info, info, info, info, info, info, info, info, info, info, info, info, info, info, info, info, info, info, info, info, info, isDebugEnabled, isDebugEnabled, isEnabled, isEnabled, isErrorEnabled, isErrorEnabled, isFatalEnabled, isFatalEnabled, isInfoEnabled, isInfoEnabled, isTraceEnabled, isTraceEnabled, isWarnEnabled, isWarnEnabled, log, log, log, log, log, log, log, log, log, log, log, log, log, log, log, log, log, log, log, log, log, log, log, log, log, log, log, log, log, log, log, log, log, log, log, log, log, log, log, log, log, log, log, log, log, log, log, log, logMessage, printf, printf, throwing, throwing, trace, trace, trace, trace, trace, trace, trace, trace, trace, trace, trace, trace, trace, trace, trace, trace, trace, trace, trace, trace, trace, trace, trace, trace, trace, trace, trace, trace, trace, trace, trace, trace, trace, trace, trace, trace, trace, trace, trace, trace, trace, trace, trace, trace, trace, trace, trace, trace, traceEntry, traceEntry, traceEntry, traceEntry, traceEntry, traceExit, traceExit, traceExit, traceExit, traceExit, traceExit, warn, warn, warn, warn, warn, warn, warn, warn, warn, warn, warn, warn, warn, warn, warn, warn, warn, warn, warn, warn, warn, warn, warn, warn, warn, warn, warn, warn, warn, warn, warn, warn, warn, warn, warn, warn, warn, warn, warn, warn, warn, warn, warn, warn, warn, warn, warn, warn
    • Constructor Detail

      • LogRecorder

        public LogRecorder()
    • Method Detail

      • getText

        public java.lang.String getText()
        Gets the text.
        Returns:
        the text
      • getRecord

        public java.lang.String getRecord()
        Gets the record.
        Returns:
        the record
      • getNumberOfRecords

        public int getNumberOfRecords()
        Gets the number of records.
        Returns:
        the number of records
      • toString

        public java.lang.String toString()
        To string.
        Overrides:
        toString in class java.lang.Object
        Returns:
        the string
        See Also:
        Object.toString()
      • getLevel

        public org.apache.logging.log4j.Level getLevel()
        Specified by:
        getLevel in interface org.apache.logging.log4j.Logger
      • isEnabled

        public boolean isEnabled​(org.apache.logging.log4j.Level level,
                                 org.apache.logging.log4j.Marker marker,
                                 org.apache.logging.log4j.message.Message message,
                                 java.lang.Throwable t)
        Specified by:
        isEnabled in interface org.apache.logging.log4j.spi.ExtendedLogger
      • isEnabled

        public boolean isEnabled​(org.apache.logging.log4j.Level level,
                                 org.apache.logging.log4j.Marker marker,
                                 java.lang.CharSequence message,
                                 java.lang.Throwable t)
        Specified by:
        isEnabled in interface org.apache.logging.log4j.spi.ExtendedLogger
      • isEnabled

        public boolean isEnabled​(org.apache.logging.log4j.Level level,
                                 org.apache.logging.log4j.Marker marker,
                                 java.lang.Object message,
                                 java.lang.Throwable t)
        Specified by:
        isEnabled in interface org.apache.logging.log4j.spi.ExtendedLogger
      • isEnabled

        public boolean isEnabled​(org.apache.logging.log4j.Level level,
                                 org.apache.logging.log4j.Marker marker,
                                 java.lang.String message,
                                 java.lang.Throwable t)
        This check returns true for all levels.
        Specified by:
        isEnabled in interface org.apache.logging.log4j.spi.ExtendedLogger
        Parameters:
        level - the level
        marker - the marker
        message - the message
        t - the t
        Returns:
        always true
        See Also:
        ExtendedLogger.isEnabled(org.apache.logging.log4j.Level, org.apache.logging.log4j.Marker, java.lang.String, java.lang.Throwable)
      • isEnabled

        public boolean isEnabled​(org.apache.logging.log4j.Level level,
                                 org.apache.logging.log4j.Marker marker,
                                 java.lang.String message)
        Specified by:
        isEnabled in interface org.apache.logging.log4j.spi.ExtendedLogger
      • isEnabled

        public boolean isEnabled​(org.apache.logging.log4j.Level level,
                                 org.apache.logging.log4j.Marker marker,
                                 java.lang.String message,
                                 java.lang.Object... params)
        Specified by:
        isEnabled in interface org.apache.logging.log4j.spi.ExtendedLogger
      • isEnabled

        public boolean isEnabled​(org.apache.logging.log4j.Level level,
                                 org.apache.logging.log4j.Marker marker,
                                 java.lang.String message,
                                 java.lang.Object p0)
        Specified by:
        isEnabled in interface org.apache.logging.log4j.spi.ExtendedLogger
      • isEnabled

        public boolean isEnabled​(org.apache.logging.log4j.Level level,
                                 org.apache.logging.log4j.Marker marker,
                                 java.lang.String message,
                                 java.lang.Object p0,
                                 java.lang.Object p1)
        Specified by:
        isEnabled in interface org.apache.logging.log4j.spi.ExtendedLogger
      • isEnabled

        public boolean isEnabled​(org.apache.logging.log4j.Level level,
                                 org.apache.logging.log4j.Marker marker,
                                 java.lang.String message,
                                 java.lang.Object p0,
                                 java.lang.Object p1,
                                 java.lang.Object p2)
        Specified by:
        isEnabled in interface org.apache.logging.log4j.spi.ExtendedLogger
      • isEnabled

        public boolean isEnabled​(org.apache.logging.log4j.Level level,
                                 org.apache.logging.log4j.Marker marker,
                                 java.lang.String message,
                                 java.lang.Object p0,
                                 java.lang.Object p1,
                                 java.lang.Object p2,
                                 java.lang.Object p3)
        Specified by:
        isEnabled in interface org.apache.logging.log4j.spi.ExtendedLogger
      • isEnabled

        public boolean isEnabled​(org.apache.logging.log4j.Level level,
                                 org.apache.logging.log4j.Marker marker,
                                 java.lang.String message,
                                 java.lang.Object p0,
                                 java.lang.Object p1,
                                 java.lang.Object p2,
                                 java.lang.Object p3,
                                 java.lang.Object p4)
        Specified by:
        isEnabled in interface org.apache.logging.log4j.spi.ExtendedLogger
      • isEnabled

        public boolean isEnabled​(org.apache.logging.log4j.Level level,
                                 org.apache.logging.log4j.Marker marker,
                                 java.lang.String message,
                                 java.lang.Object p0,
                                 java.lang.Object p1,
                                 java.lang.Object p2,
                                 java.lang.Object p3,
                                 java.lang.Object p4,
                                 java.lang.Object p5)
        Specified by:
        isEnabled in interface org.apache.logging.log4j.spi.ExtendedLogger
      • isEnabled

        public boolean isEnabled​(org.apache.logging.log4j.Level level,
                                 org.apache.logging.log4j.Marker marker,
                                 java.lang.String message,
                                 java.lang.Object p0,
                                 java.lang.Object p1,
                                 java.lang.Object p2,
                                 java.lang.Object p3,
                                 java.lang.Object p4,
                                 java.lang.Object p5,
                                 java.lang.Object p6)
        Specified by:
        isEnabled in interface org.apache.logging.log4j.spi.ExtendedLogger
      • isEnabled

        public boolean isEnabled​(org.apache.logging.log4j.Level level,
                                 org.apache.logging.log4j.Marker marker,
                                 java.lang.String message,
                                 java.lang.Object p0,
                                 java.lang.Object p1,
                                 java.lang.Object p2,
                                 java.lang.Object p3,
                                 java.lang.Object p4,
                                 java.lang.Object p5,
                                 java.lang.Object p6,
                                 java.lang.Object p7)
        Specified by:
        isEnabled in interface org.apache.logging.log4j.spi.ExtendedLogger
      • isEnabled

        public boolean isEnabled​(org.apache.logging.log4j.Level level,
                                 org.apache.logging.log4j.Marker marker,
                                 java.lang.String message,
                                 java.lang.Object p0,
                                 java.lang.Object p1,
                                 java.lang.Object p2,
                                 java.lang.Object p3,
                                 java.lang.Object p4,
                                 java.lang.Object p5,
                                 java.lang.Object p6,
                                 java.lang.Object p7,
                                 java.lang.Object p8)
        Specified by:
        isEnabled in interface org.apache.logging.log4j.spi.ExtendedLogger
      • isEnabled

        public boolean isEnabled​(org.apache.logging.log4j.Level level,
                                 org.apache.logging.log4j.Marker marker,
                                 java.lang.String message,
                                 java.lang.Object p0,
                                 java.lang.Object p1,
                                 java.lang.Object p2,
                                 java.lang.Object p3,
                                 java.lang.Object p4,
                                 java.lang.Object p5,
                                 java.lang.Object p6,
                                 java.lang.Object p7,
                                 java.lang.Object p8,
                                 java.lang.Object p9)
        Specified by:
        isEnabled in interface org.apache.logging.log4j.spi.ExtendedLogger
      • logMessage

        public void logMessage​(java.lang.String fqcn,
                               org.apache.logging.log4j.Level level,
                               org.apache.logging.log4j.Marker marker,
                               org.apache.logging.log4j.message.Message message,
                               java.lang.Throwable t)
        The message is logged and recorded here.
        Specified by:
        logMessage in interface org.apache.logging.log4j.spi.ExtendedLogger
        Parameters:
        fqcn - the fqcn
        level - the level
        marker - the marker
        message - the message
        t - the t
        See Also:
        ExtendedLogger.logMessage(String, Level, Marker, Message, Throwable)