Package com.log4rich.core
Class Logger
java.lang.Object
com.log4rich.core.Logger
Main logger class that handles log events.
Thread-safe implementation using concurrent collections.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAppender(Appender appender) Adds an appender to this logger.voidRemoves all appenders from this logger.voidLogs a message at DEBUG level.voidLogs a message at DEBUG level with an associated throwable.voidLogs a message at ERROR level.voidLogs a message at ERROR level with an associated throwable.voidLogs a message at FATAL level.voidLogs a message at FATAL level with an associated throwable.Gets a copy of all appenders associated with this logger.getLevel()Gets the current log level for this logger.getName()Gets the name of this logger.voidLogs a message at INFO level.voidLogs a message at INFO level with an associated throwable.booleanChecks if DEBUG level is enabled for this logger.booleanChecks if ERROR level is enabled for this logger.booleanChecks if FATAL level is enabled for this logger.booleanChecks if INFO level is enabled for this logger.booleanisLevelEnabled(LogLevel level) Checks if the specified level is enabled for this logger.booleanChecks if location capture is enabled for this logger.booleanChecks if TRACE level is enabled for this logger.booleanChecks if WARN level is enabled for this logger.voidremoveAppender(Appender appender) Removes an appender from this logger.voidremoveAppender(String name) Removes an appender from this logger by name.voidSets the log level for this logger.voidsetLocationCapture(boolean enabled) Sets whether this logger should capture location information.voidshutdown()Closes all appenders associated with this logger.voidLogs a message at TRACE level.voidLogs a message at TRACE level with an associated throwable.voidLogs a message at WARN level.voidLogs a message at WARN level with an associated throwable.
-
Constructor Details
-
Logger
Creates a new logger with the specified name. The logger is initialized with INFO level and location capture enabled.- Parameters:
name- the name of the logger
-
-
Method Details
-
trace
Logs a message at TRACE level.- Parameters:
message- the message to log
-
trace
Logs a message at TRACE level with an associated throwable.- Parameters:
message- the message to logthrowable- the throwable to log
-
debug
Logs a message at DEBUG level.- Parameters:
message- the message to log
-
debug
Logs a message at DEBUG level with an associated throwable.- Parameters:
message- the message to logthrowable- the throwable to log
-
info
Logs a message at INFO level.- Parameters:
message- the message to log
-
info
Logs a message at INFO level with an associated throwable.- Parameters:
message- the message to logthrowable- the throwable to log
-
warn
Logs a message at WARN level.- Parameters:
message- the message to log
-
warn
Logs a message at WARN level with an associated throwable.- Parameters:
message- the message to logthrowable- the throwable to log
-
error
Logs a message at ERROR level.- Parameters:
message- the message to log
-
error
Logs a message at ERROR level with an associated throwable.- Parameters:
message- the message to logthrowable- the throwable to log
-
fatal
Logs a message at FATAL level.- Parameters:
message- the message to log
-
fatal
Logs a message at FATAL level with an associated throwable.- Parameters:
message- the message to logthrowable- the throwable to log
-
isTraceEnabled
public boolean isTraceEnabled()Checks if TRACE level is enabled for this logger.- Returns:
- true if TRACE level is enabled, false otherwise
-
isDebugEnabled
public boolean isDebugEnabled()Checks if DEBUG level is enabled for this logger.- Returns:
- true if DEBUG level is enabled, false otherwise
-
isInfoEnabled
public boolean isInfoEnabled()Checks if INFO level is enabled for this logger.- Returns:
- true if INFO level is enabled, false otherwise
-
isWarnEnabled
public boolean isWarnEnabled()Checks if WARN level is enabled for this logger.- Returns:
- true if WARN level is enabled, false otherwise
-
isErrorEnabled
public boolean isErrorEnabled()Checks if ERROR level is enabled for this logger.- Returns:
- true if ERROR level is enabled, false otherwise
-
isFatalEnabled
public boolean isFatalEnabled()Checks if FATAL level is enabled for this logger.- Returns:
- true if FATAL level is enabled, false otherwise
-
isLevelEnabled
Checks if the specified level is enabled for this logger.- Parameters:
level- the level to check- Returns:
- true if the level is enabled, false otherwise
-
addAppender
Adds an appender to this logger.- Parameters:
appender- the appender to add, null values are ignored
-
removeAppender
Removes an appender from this logger.- Parameters:
appender- the appender to remove, null values are ignored
-
removeAppender
Removes an appender from this logger by name.- Parameters:
name- the name of the appender to remove, null values are ignored
-
getAppenders
Gets a copy of all appenders associated with this logger.- Returns:
- a list of appenders (copy, not live view)
-
clearAppenders
public void clearAppenders()Removes all appenders from this logger. -
setLevel
Sets the log level for this logger.- Parameters:
level- the log level to set, null values default to INFO
-
getLevel
Gets the current log level for this logger.- Returns:
- the current log level
-
getName
Gets the name of this logger.- Returns:
- the logger name
-
setLocationCapture
public void setLocationCapture(boolean enabled) Sets whether this logger should capture location information.- Parameters:
enabled- true to enable location capture, false to disable
-
isLocationCaptureEnabled
public boolean isLocationCaptureEnabled()Checks if location capture is enabled for this logger.- Returns:
- true if location capture is enabled, false otherwise
-
shutdown
public void shutdown()Closes all appenders associated with this logger. This method is called during shutdown to ensure proper resource cleanup.
-