Package org.slf4j.spi

Interface LoggingEventBuilder

All Known Implementing Classes:
DefaultLoggingEventBuilder, NOPLoggingEventBuilder

public interface LoggingEventBuilder
This is the central interface in slf4j's fluent API for creating logging events.
Since:
2.0.0
Author:
Ceki Gülcü
  • Method Details

    • setCause

      Set the cause for the logging event being built.
      Parameters:
      cause - a throwable
      Returns:
      a LoggingEventBuilder instance, usually this.
    • addMarker

      A marker to the event being built.
      Parameters:
      marker - a Marker instance to add.
      Returns:
      a LoggingEventBuilder instance, usually this.
    • addArgument

      Add an argument to the event being built. Synonymous with arg(Object) method.
      Parameters:
      p - an Object to add.
      Returns:
      a LoggingEventBuilder instance, usually this.
    • arg

      Add an argument to the event being built. Synonymous with addArgument(Object) method.
      Parameters:
      p - an Object to add.
      Returns:
      a LoggingEventBuilder instance, usually this.
      Since:
      2.1.0
    • addArgument

      Add an argument supplier to the event being built. Synonymous with arg(Supplier) method.

      Parameters:
      objectSupplier - an Object supplier to add.
      Returns:
      a LoggingEventBuilder instance, usually this.
    • arg

      @CheckReturnValue default LoggingEventBuilder arg(Supplier<?> objectSupplier)

      Add an argument supplier to the event being built. Synonymous with addArgument(Supplier) method.

      Parameters:
      objectSupplier - an Object supplier to add.
      Returns:
      a LoggingEventBuilder instance, usually this.
      Since:
      2.1.0
    • arg

      default LoggingEventBuilder arg(boolean b)
      Add a value of type boolean to the event being built.

      The default implementation simply casts to Boolean. However, the NOP implementation, i.e. NOPLoggingEventBuilder, skips the cast.

      Parameters:
      b - a value of type boolean value to add.
      Returns:
      a LoggingEventBuilder instance, usually this.
      Since:
      2.1.0
    • arg

      default LoggingEventBuilder arg(char c)
      Add a value of type char to the event being built.

      The default implementation simply casts to Character. However, the NOP implementation, i.e. NOPLoggingEventBuilder, skips the cast.

      Parameters:
      c - a value of type char value to add.
      Returns:
      a LoggingEventBuilder instance, usually this.
      Since:
      2.1.0
    • arg

      default LoggingEventBuilder arg(byte b)
      Add a value of type byte to the event being built.

      The default implementation simply casts to Byte. However, the NOP implementation, i.e. NOPLoggingEventBuilder, skips the cast.

      Parameters:
      b - a value of type byte value to add.
      Returns:
      a LoggingEventBuilder instance, usually this.
      Since:
      2.1.0
    • arg

      default LoggingEventBuilder arg(short s)
      Add a value of type short to the event being built.

      The default implementation simply casts to Short. However, the NOP implementation, i.e. NOPLoggingEventBuilder, skips the cast.

      Parameters:
      s - a value of type short value to add.
      Returns:
      a LoggingEventBuilder instance, usually this.
      Since:
      2.1.0
    • arg

      default LoggingEventBuilder arg(int i)
      Add a value of type int to the event being built.

      The default implementation simply casts to Integer. However, the NOP implementation, i.e. NOPLoggingEventBuilder, skips the cast.

      Parameters:
      i - a value of type int value to add.
      Returns:
      a LoggingEventBuilder instance, usually this.
      Since:
      2.1.0
    • arg

      default LoggingEventBuilder arg(long l)
      Add a value of type long to the event being built.

      The default implementation simply casts to Long. However, the NOP implementation, i.e. NOPLoggingEventBuilder, skips the cast.

      Parameters:
      l - a value of type long value to add.
      Returns:
      a LoggingEventBuilder instance, usually this.
      Since:
      2.1.0
    • arg

      default LoggingEventBuilder arg(float f)
      Add a value of type float to the event being built.

      The default implementation simply casts to Float. However, the NOP implementation, i.e. NOPLoggingEventBuilder, skips the cast.

      Parameters:
      f - a value of type float value to add.
      Returns:
      a LoggingEventBuilder instance, usually this.
      Since:
      2.1.0
    • arg

      default LoggingEventBuilder arg(double d)
      Add a value of type double to the event being built.

      The default implementation simply casts to Double. However, the NOP implementation skips the cast.

      Parameters:
      d - a value of type double value to add.
      Returns:
      a LoggingEventBuilder instance, usually this.
      Since:
      2.1.0
    • addKeyValue

      Add a key value pair to the event being built.
      Parameters:
      key - the key of the key value pair.
      value - the value of the key value pair.
      Returns:
      a LoggingEventBuilder instance, usually this.
    • kv

      Add a key value pair to the event being built. Synonymous with addKeyValue(String, Object) method.
      Parameters:
      key - the key of the key value pair.
      value - the value of the key value pair.
      Returns:
      a LoggingEventBuilder instance, usually this.
      Since:
      2.1.0
    • addKeyValue

      Add a key value pair to the event being built.
      Parameters:
      key - the key of the key value pair.
      valueSupplier - a supplier of a value for the key value pair.
      Returns:
      a LoggingEventBuilder instance, usually this.
    • kv

      Add a key value pair to the event being built. Synonymous with addKeyValue(String, Supplier) method.
      Parameters:
      key - the key of the key value pair.
      valueSupplier - a supplier of a value for the key value pair.
      Returns:
      a LoggingEventBuilder instance, usually this.
      Since:
      2.1.0
    • kv

      default LoggingEventBuilder kv(String key, boolean b)

      Add a key value pair to the event being built, with the value part being of type boolean.

      The default implementation simply casts to value part to Boolean before calling addKeyValue(String, Object). However, the NOP implementation, i.e NOPLoggingEventBuilder, skips the cast.

      Parameters:
      key - the key of the key value pair.
      b - the value of type boolean of the key value pair.
      Returns:
      a LoggingEventBuilder instance, usually this.
      Since:
      2.1.0
    • kv

      default LoggingEventBuilder kv(String key, char c)

      Add a key value pair to the event being built, with the value part being of type char.

      The default implementation simply casts to value part to Character before calling addKeyValue(String, Object). However, the NOP implementation, i.e NOPLoggingEventBuilder, skips the cast.

      Parameters:
      key - the key of the key value pair.
      c - the value of type char of the key value pair.
      Returns:
      a LoggingEventBuilder instance, usually this.
      Since:
      2.1.0
    • kv

      default LoggingEventBuilder kv(String key, byte b)

      Add a key value pair to the event being built, with the value part being of type byte.

      The default implementation simply casts to value part to Byte before calling addKeyValue(String, Object). However, the NOP implementation, i.e NOPLoggingEventBuilder, skips the cast.

      Parameters:
      key - the key of the key value pair.
      b - the value of type byte of the key value pair.
      Returns:
      a LoggingEventBuilder instance, usually this.
      Since:
      2.1.0
    • kv

      default LoggingEventBuilder kv(String key, short s)

      Add a key value pair to the event being built, with the value part being of type short.

      The default implementation simply casts to value part to Short before calling addKeyValue(String, Object). However, the NOP implementation, i.e NOPLoggingEventBuilder, skips the cast.

      Parameters:
      key - the key of the key value pair.
      s - the value of type short of the key value pair.
      Returns:
      a LoggingEventBuilder instance, usually this.
      Since:
      2.1.0
    • kv

      default LoggingEventBuilder kv(String key, int i)

      Add a key value pair to the event being built, with the value part being of type int.

      The default implementation simply casts to value part to Integer before calling addKeyValue(String, Object). However, the NOP implementation, i.e NOPLoggingEventBuilder, skips the cast.

      Parameters:
      key - the key of the key value pair.
      i - the value of type int of the key value pair.
      Returns:
      a LoggingEventBuilder instance, usually this.
      Since:
      2.1.0
    • kv

      default LoggingEventBuilder kv(String key, long l)

      Add a key value pair to the event being built, with the value part being of type long.

      The default implementation simply casts to value part to Integer before calling addKeyValue(String, Object). However, the NOP implementation, i.e NOPLoggingEventBuilder, skips the cast.

      Parameters:
      key - the key of the key value pair.
      l - the value of type long of the key value pair.
      Returns:
      a LoggingEventBuilder instance, usually this.
      Since:
      2.1.0
    • kv

      default LoggingEventBuilder kv(String key, float f)

      Add a key value pair to the event being built, with the value part being of type float.

      The default implementation simply casts to value part to Float before calling addKeyValue(String, Object). However, the NOP implementation, i.e NOPLoggingEventBuilder, skips the cast.

      Parameters:
      key - the key of the key value pair.
      f - the value of type float of the key value pair.
      Returns:
      a LoggingEventBuilder instance, usually this.
      Since:
      2.1.0
    • kv

      default LoggingEventBuilder kv(String key, double f)

      Add a key value pair to the event being built, with the value part being of type double.

      The default implementation simply casts to value part to Double before calling addKeyValue(String, Object). However, the NOP implementation, i.e NOPLoggingEventBuilder, skips the cast.

      Parameters:
      key - the key of the key value pair.
      f - the value of type double of the key value pair.
      Returns:
      a LoggingEventBuilder instance, usually this.
      Since:
      2.1.0
    • setMessage

      Sets the message of the logging event.
      Parameters:
      message - the message of the event
      Returns:
      a LoggingEventBuilder instance, usually this.
      Since:
      2.0.0
    • setMessage

      Sets the message of the event via a message supplier.
      Parameters:
      messageSupplier - supplies a String to be used as the message for the event
      Returns:
      a LoggingEventBuilder instance, usually this.
      Since:
      2.0.0-beta0
    • log

      void log()
      After the logging event is built, performs actual logging. This method must be called for logging to occur. If the call to log() is omitted, a LoggingEvent will be built but no logging will occur.
      Since:
      2.0.0-beta0
    • log

      void log(String message)
      Equivalent to calling setMessage(String) followed by log();
      Parameters:
      message - the message to log
    • log

      void log(String message, Object arg)
      Equivalent to calling setMessage(String) followed by addArgument(Object)} and then log()
      Parameters:
      message - the message to log
      arg - an argument to be used with the message to log
    • log

      void log(String message, Object arg0, Object arg1)
      Equivalent to calling setMessage(String) followed by two calls to addArgument(Object) and then log()
      Parameters:
      message - the message to log
      arg0 - first argument to be used with the message to log
      arg1 - second argument to be used with the message to log
    • log

      void log(String message, Object... args)
      Equivalent to calling setMessage(String) followed by zero or more calls to addArgument(Object) (depending on the size of args array) and then log()
      Parameters:
      message - the message to log
      args - a list (actually an array) of arguments to be used with the message to log
    • log

      void log(Supplier<String> messageSupplier)
      Equivalent to calling setMessage(Supplier) followed by log()
      Parameters:
      messageSupplier - a Supplier returning a message of type String