Class LogConfig

java.lang.Object
org.apache.juneau.microservice.LogConfig

public class LogConfig extends Object
Can be used for configuration of simple logging in the microservice.

Instances of this class can be created using create() and passing the result to Microservice.Builder.logConfig(LogConfig).

These values override values specified in the "Logging" configuration section.

  • Constructor Details

    • LogConfig

      protected LogConfig(LogConfig copyFrom)
      Copy constructor.
      Parameters:
      copyFrom - The log config to copy from.
  • Method Details

    • copy

      public LogConfig copy()
      Creates a copy of this log configuration.
      Returns:
      A new copy of this log configuration.
    • create

      public static LogConfig create()
      Creates a new instance of this config.
      Returns:
      A new instance of this config.
    • logFile

      public LogConfig logFile(String logFile)
      Returns the name of the log file on the file system to store the log file for this microservice.

      This overrides the configuration value "Logging/logFile". If not specified, no file system logging will be used.

      Parameters:
      logFile - The log file.
      Returns:
      This object (for method chaining).
    • logDir

      public LogConfig logDir(String logDir)
      The location of the log directory to create the log file.

      This overrides the configuration value "Logging/logDir". If not specified, uses the JVM working directory.

      Parameters:
      logDir - The log directory location as a path relative to the working directory.
      Returns:
      This object (for method chaining).
    • formatter

      public LogConfig formatter(Formatter formatter)
      The log entry formatter.

      If not specified, uses the following values pulled from the configuration to construct a LogEntryFormatter:

      • "Logging/format" (default is "[{date} {level}] {msg}%n")
      • "Logging/dateFormat" (default is "yyyy.MM.dd hh:mm:ss")
      • "Logging/useStackTraceHashes" (default is false)
      Parameters:
      formatter - The log entry formatter.
      Returns:
      This object (for method chaining).
      See Also:
    • append

      public LogConfig append()
      Specified append mode for the log file.
      Returns:
      This object (for method chaining).
    • limit

      public LogConfig limit(int limit)
      The maximum number of bytes to write to any one log file.
      Parameters:
      limit - The number of bytes.
      Returns:
      This object (for method chaining).
    • count

      public LogConfig count(int count)
      The number of log files to use.
      Parameters:
      count - The number of log files.
      Returns:
      This object (for method chaining).
    • fileLevel

      public LogConfig fileLevel(Level fileLevel)
      The default logging level for the log file.
      Parameters:
      fileLevel - The logging level.
      Returns:
      This object (for method chaining).
    • consoleLevel

      public LogConfig consoleLevel(Level consoleLevel)
      The default logging level for the console.
      Parameters:
      consoleLevel - The logging level.
      Returns:
      This object (for method chaining).
    • levels

      public LogConfig levels(Map<String,Level> levels)
      Default logging levels for loggers.
      Parameters:
      levels - A map of logger names to logger levels.
      Returns:
      This object (for method chaining).
    • level

      public LogConfig level(String logger, Level level)
      Default logging level for logger.
      Parameters:
      logger - Logger name.
      level - Logger level.
      Returns:
      This object (for method chaining).