Class Configuration

java.lang.Object
com.log4rich.config.Configuration

public class Configuration extends Object
Configuration management for log4Rich. Holds all configuration settings loaded from the config file. This class provides type-safe access to configuration properties and maintains default values for all settings.
  • Constructor Details

    • Configuration

      public Configuration()
      Creates a new Configuration with default settings. All properties are initialized to their default values.
    • Configuration

      public Configuration(Properties properties)
      Creates a new Configuration with the specified properties. Default values are set first, then overridden with provided properties.
      Parameters:
      properties - the properties to use for configuration
  • Method Details

    • getRootLevel

      public LogLevel getRootLevel()
      Gets the root logger level.
      Returns:
      the root logger level
    • isConsoleEnabled

      public boolean isConsoleEnabled()
      Checks if console logging is enabled.
      Returns:
      true if console logging is enabled, false otherwise
    • isFileEnabled

      public boolean isFileEnabled()
      Checks if file logging is enabled.
      Returns:
      true if file logging is enabled, false otherwise
    • getConsoleTarget

      public String getConsoleTarget()
      Gets the console target stream (STDOUT or STDERR).
      Returns:
      the console target stream
    • getConsoleLevel

      public LogLevel getConsoleLevel()
      Gets the console log level, falling back to root level if not set.
      Returns:
      the console log level
    • getConsolePattern

      public String getConsolePattern()
      Gets the console log pattern for formatting.
      Returns:
      the console log pattern
    • getFilePath

      public String getFilePath()
      Gets the file path for logging.
      Returns:
      the file path
    • getFileLevel

      public LogLevel getFileLevel()
      Gets the file log level, falling back to root level if not set.
      Returns:
      the file log level
    • getFilePattern

      public String getFilePattern()
      Gets the file log pattern for formatting.
      Returns:
      the file log pattern
    • getMaxSize

      public String getMaxSize()
      Gets the maximum file size before rolling over.
      Returns:
      the maximum file size (e.g., "10M", "100K")
    • getMaxBackups

      public int getMaxBackups()
      Gets the maximum number of backup files to keep.
      Returns:
      the maximum number of backup files
    • isCompressionEnabled

      public boolean isCompressionEnabled()
      Checks if compression is enabled for rolled files.
      Returns:
      true if compression is enabled, false otherwise
    • getCompressionProgram

      public String getCompressionProgram()
      Gets the compression program to use for rolled files.
      Returns:
      the compression program name (e.g., "gzip", "bzip2")
    • getCompressionArgs

      public String getCompressionArgs()
      Gets the arguments to pass to the compression program.
      Returns:
      the compression program arguments
    • getFileEncoding

      public String getFileEncoding()
      Gets the file encoding to use for log files.
      Returns:
      the file encoding (e.g., "UTF-8", "ISO-8859-1")
    • getBufferSize

      public int getBufferSize()
      Gets the buffer size for file I/O operations.
      Returns:
      the buffer size in bytes
    • isImmediateFlush

      public boolean isImmediateFlush()
      Checks if immediate flush is enabled for file operations.
      Returns:
      true if immediate flush is enabled, false otherwise
    • isLocationCapture

      public boolean isLocationCapture()
      Checks if location capture is enabled (class, method, line number).
      Returns:
      true if location capture is enabled, false otherwise
    • getLockTimeout

      public long getLockTimeout()
      Gets the lock timeout for thread synchronization.
      Returns:
      the lock timeout in milliseconds
    • getDatePattern

      public String getDatePattern()
      Gets the date pattern used for backup file naming.
      Returns:
      the date pattern (e.g., "yyyy-MM-dd-HH-mm-ss")
    • isTruncateLoggerNames

      public boolean isTruncateLoggerNames()
      Checks if logger names should be truncated for display.
      Returns:
      true if logger names should be truncated, false otherwise
    • getMaxLoggerNameLength

      public int getMaxLoggerNameLength()
      Gets the maximum length for logger names when truncation is enabled.
      Returns:
      the maximum logger name length
    • getClassFormat

      public String getClassFormat()
      Gets the class name format for display (SIMPLE, FULL, etc.).
      Returns:
      the class name format
    • getLoggerLevels

      public Map<String,LogLevel> getLoggerLevels()
      Gets a copy of all logger-specific levels.
      Returns:
      a map of logger names to their specific levels
    • getLoggerLevel

      public LogLevel getLoggerLevel(String loggerName)
      Gets the specific level for a logger, or null if not set.
      Parameters:
      loggerName - the name of the logger
      Returns:
      the specific level for the logger, or null if not set
    • setLoggerLevel

      public void setLoggerLevel(String loggerName, LogLevel level)
      Sets the specific level for a logger.
      Parameters:
      loggerName - the name of the logger
      level - the level to set for the logger
    • getProperty

      public String getProperty(String key)
      Gets a property value by key.
      Parameters:
      key - the property key
      Returns:
      the property value, or null if not found
    • getProperty

      public String getProperty(String key, String defaultValue)
      Gets a property value by key with a default value.
      Parameters:
      key - the property key
      defaultValue - the default value if the key is not found
      Returns:
      the property value, or the default value if not found
    • getProperties

      public Properties getProperties()
      Gets the underlying Properties object. This returns the actual properties object, not a copy.
      Returns:
      the Properties object containing all configuration