Class ColorConverter

java.lang.Object
org.apache.logging.log4j.core.pattern.AbstractPatternConverter
org.apache.logging.log4j.core.pattern.LogEventPatternConverter
org.springframework.boot.logging.log4j2.ColorConverter
All Implemented Interfaces:
org.apache.logging.log4j.core.pattern.PatternConverter

@Plugin(name="color", category="Converter") public final class ColorConverter extends org.apache.logging.log4j.core.pattern.LogEventPatternConverter
Log4j2 LogEventPatternConverter to color output using the AnsiOutput class. One or more styling options can be provided to the converter, or if not specified color styling will be picked based on the logging level. Supported options include foreground colors (e.g. red, bright_blue), background colors (e.g. bg_red, bg_bright_green), and text styles (e.g. bold, underline, reverse).
Since:
1.3.0
  • Field Summary

    Fields inherited from class org.apache.logging.log4j.core.pattern.AbstractPatternConverter

    LOGGER

    Fields inherited from interface org.apache.logging.log4j.core.pattern.PatternConverter

    CATEGORY
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    appendAnsiString(StringBuilder toAppendTo, String in, AnsiElement... elements)
     
    void
    format(org.apache.logging.log4j.core.LogEvent event, StringBuilder toAppendTo)
     
    boolean
     
    static @Nullable ColorConverter
    newInstance(@Nullable org.apache.logging.log4j.core.config.Configuration config, @Nullable String[] options)
    Creates a new instance of the class.

    Methods inherited from class org.apache.logging.log4j.core.pattern.LogEventPatternConverter

    emptyVariableOutput, format, isVariable

    Methods inherited from class org.apache.logging.log4j.core.pattern.AbstractPatternConverter

    getName, getStyleClass

    Methods inherited from class Object

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

    • handlesThrowable

      public boolean handlesThrowable()
      Overrides:
      handlesThrowable in class org.apache.logging.log4j.core.pattern.LogEventPatternConverter
    • format

      public void format(org.apache.logging.log4j.core.LogEvent event, StringBuilder toAppendTo)
      Specified by:
      format in class org.apache.logging.log4j.core.pattern.LogEventPatternConverter
    • appendAnsiString

      protected void appendAnsiString(StringBuilder toAppendTo, String in, AnsiElement... elements)
    • newInstance

      public static @Nullable ColorConverter newInstance(@Nullable org.apache.logging.log4j.core.config.Configuration config, @Nullable String[] options)
      Creates a new instance of the class. Required by Log4J2.
      Parameters:
      config - the configuration
      options - the options
      Returns:
      a new instance, or null if the options are invalid