Class LogRecord


  • public class LogRecord
    extends Object
    LogRecord objects are used to pass logging requests between the logging framework and individual log Handlers.

    When a LogRecord is passed into the logging framework it logically belongs to the framework and should no longer be used or updated by the client application.

    Note that if the client application has not specified an explicit source method name and source class name, then the LogRecord class will infer them automatically when they are first accessed (due to a call on getSourceMethodName or getSourceClassName) by analyzing the call stack. Therefore, if a logging Handler wants to pass off a LogRecord to another thread, or to transmit it over RMI, and if it wishes to subsequently obtain method name or class name information it should call one of getSourceClassName or getSourceMethodName to force the values to be filled in.

    • Constructor Detail

      • LogRecord

        public LogRecord​(Level level,
                         @Nullable
                         String msg)
        Construct a LogRecord with the given level and message.
        Parameters:
        level - a logging level value.
        msg - the logging message (may be null).
    • Method Detail

      • getLoggerName

        @Nullable
        public String getLoggerName()
        Get the name of the logger that logged this LogRecord.
        Returns:
        source logger name (may be null).
      • setLoggerName

        public void setLoggerName​(@Nullable
                                  String name)
        Set the source logger's name.
        Parameters:
        name - the source logger's name (may be null).
      • getLevel

        public Level getLevel()
        Get the logging message level.
        Returns:
        the logging message level.
      • setLevel

        public void setLevel​(Level level)
        Set the logging message level.
        Parameters:
        level - the logging message level.
      • getSequenceNumber

        public long getSequenceNumber()
        Get the sequence number of the LogRecord. This number is normally a unique identifier assigned by the constructor.
        Returns:
        the sequence number of the LogRecord.
      • getMessage

        @Nullable
        public String getMessage()
        Get the raw log message.
        Returns:
        the message string (may be null).
      • setMessage

        public void setMessage​(@Nullable
                               String message)
        Set the raw log message.
        Parameters:
        message - the message to set (may be null).
      • getMillis

        public long getMillis()
        Get event time in milliseconds since 1970. This is the creation time of the LogRecord.
        Returns:
        event time in milliseconds.
      • setMillis

        public void setMillis​(long millis)
        Set event time of the LogRecord.
        Parameters:
        millis - event time.
      • getThrown

        @Nullable
        public Throwable getThrown()
        Get the throwable associated with this log record, if any.
        Returns:
        a throwable (may be null).
      • setThrown

        public void setThrown​(@Nullable
                              Throwable thrown)
        Set the throwable associated with this log record.
        Parameters:
        thrown - a throwable (may be null)