Package com.log4rich.config
Class Configuration
java.lang.Object
com.log4rich.config.Configuration
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 Summary
ConstructorsConstructorDescriptionCreates a new Configuration with default settings.Configuration
(Properties properties) Creates a new Configuration with the specified properties. -
Method Summary
Modifier and TypeMethodDescriptionint
Gets the buffer size for file I/O operations.Gets the class name format for display (SIMPLE, FULL, etc.).Gets the arguments to pass to the compression program.Gets the compression program to use for rolled files.Gets the console log level, falling back to root level if not set.Gets the console log pattern for formatting.Gets the console target stream (STDOUT or STDERR).Gets the date pattern used for backup file naming.Gets the file encoding to use for log files.Gets the file log level, falling back to root level if not set.Gets the file path for logging.Gets the file log pattern for formatting.long
Gets the lock timeout for thread synchronization.getLoggerLevel
(String loggerName) Gets the specific level for a logger, or null if not set.Gets a copy of all logger-specific levels.int
Gets the maximum number of backup files to keep.int
Gets the maximum length for logger names when truncation is enabled.Gets the maximum file size before rolling over.Gets the underlying Properties object.getProperty
(String key) Gets a property value by key.getProperty
(String key, String defaultValue) Gets a property value by key with a default value.Gets the root logger level.boolean
Checks if compression is enabled for rolled files.boolean
Checks if console logging is enabled.boolean
Checks if file logging is enabled.boolean
Checks if immediate flush is enabled for file operations.boolean
Checks if location capture is enabled (class, method, line number).boolean
Checks if logger names should be truncated for display.void
setLoggerLevel
(String loggerName, LogLevel level) Sets the specific level for a logger.
-
Constructor Details
-
Configuration
public Configuration()Creates a new Configuration with default settings. All properties are initialized to their default values. -
Configuration
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
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
Gets the console target stream (STDOUT or STDERR).- Returns:
- the console target stream
-
getConsoleLevel
Gets the console log level, falling back to root level if not set.- Returns:
- the console log level
-
getConsolePattern
Gets the console log pattern for formatting.- Returns:
- the console log pattern
-
getFilePath
Gets the file path for logging.- Returns:
- the file path
-
getFileLevel
Gets the file log level, falling back to root level if not set.- Returns:
- the file log level
-
getFilePattern
Gets the file log pattern for formatting.- Returns:
- the file log pattern
-
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
Gets the compression program to use for rolled files.- Returns:
- the compression program name (e.g., "gzip", "bzip2")
-
getCompressionArgs
Gets the arguments to pass to the compression program.- Returns:
- the compression program arguments
-
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
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
Gets the class name format for display (SIMPLE, FULL, etc.).- Returns:
- the class name format
-
getLoggerLevels
Gets a copy of all logger-specific levels.- Returns:
- a map of logger names to their specific levels
-
getLoggerLevel
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
Sets the specific level for a logger.- Parameters:
loggerName
- the name of the loggerlevel
- the level to set for the logger
-
getProperty
Gets a property value by key.- Parameters:
key
- the property key- Returns:
- the property value, or null if not found
-
getProperty
Gets a property value by key with a default value.- Parameters:
key
- the property keydefaultValue
- the default value if the key is not found- Returns:
- the property value, or the default value if not found
-
getProperties
Gets the underlying Properties object. This returns the actual properties object, not a copy.- Returns:
- the Properties object containing all configuration
-