public class FileLogger extends Object implements com.groupdocs.foundation.logging.ILogger
The FileLogger class provides functionality to write log messages to a file. It implements the ILogger interface
and can be used to log various events and messages in an application. Log messages are written to the specified file.
Example usage:
// Create a new instance of FileLogger with the specified log file path
FileLogger fileLogger = new FileLogger("/path/to/logfile.txt");
// Log an informational message
fileLogger.debug("Debug message");
// Log an error message
fileLogger.error("Error message");
// Check is logging warning messages enabled
boolean warningEnabled = fileLogger.isWarningEnabled();
Note: The FileLogger class provides basic logging functionality.
You can extend this class to add custom log levels or additional logging features as per your requirements.
ILogger| Modifier and Type | Field and Description |
|---|---|
static String |
EXCEPTION |
static String |
MESSAGE |
| Constructor and Description |
|---|
FileLogger(String fileName)
Creates a logger that logs messages to a file specified by the provided file name.
|
FileLogger(String fileName,
boolean isTraceEnabled,
boolean isDebugEnabled,
boolean isWarningEnabled,
boolean isErrorEnabled)
Creates a logger that logs messages to a file with specified logging levels.
|
| Modifier and Type | Method and Description |
|---|---|
void |
debug(String message,
Object... arguments)
Writes a debug log message to the console.
|
void |
debug(Throwable throwable,
String message,
Object... arguments)
Writes a debug log message to the console.
|
void |
error(String message,
Object... arguments)
Writes an error log message to the console.
|
void |
error(Throwable throwable,
String message,
Object... arguments)
Writes an error log message to the console.
|
boolean |
isDebugEnabled()
Checks if the debug level is enabled for logging.
|
boolean |
isErrorEnabled()
Checks if error-level logging is enabled.
|
boolean |
isTraceEnabled()
Checks if the trace level is enabled for logging.
|
boolean |
isWarningEnabled()
Checks if the warning level is enabled for logging.
|
void |
trace(String message,
Object... arguments)
Writes a trace message to the console.
|
void |
trace(Throwable throwable,
String message,
Object... arguments)
Writes a trace log message to the console.
|
void |
warning(String message,
Object... arguments)
Writes a warning log message to the console.
|
void |
warning(Throwable throwable,
String message,
Object... arguments)
Writes a warning log message to the console.
|
public static final String EXCEPTION
public static final String MESSAGE
public FileLogger(String fileName)
Creates a logger that logs messages to a file specified by the provided file name.
fileName - The full file name with path.public FileLogger(String fileName, boolean isTraceEnabled, boolean isDebugEnabled, boolean isWarningEnabled, boolean isErrorEnabled)
Creates a logger that logs messages to a file with specified logging levels.
fileName - The full file name with path.isTraceEnabled - Specifies whether trace level logging is enabled.isDebugEnabled - Specifies whether debug level logging is enabled.isWarningEnabled - Specifies whether warning level logging is enabled.isErrorEnabled - Specifies whether error level logging is enabled.public void debug(String message, Object... arguments)
Writes a debug log message to the console. Debug log messages provide information about different processes in the application flow.
debug in interface com.groupdocs.foundation.logging.ILoggermessage - The debug log message.arguments - The arguments to be replaced in the message. They will replace {} placeholders in the order they are passed.public void debug(Throwable throwable, String message, Object... arguments)
Writes a debug log message to the console. Debug log messages provide information about different processes in the application flow.
debug in interface com.groupdocs.foundation.logging.ILoggermessage - The debug log message.arguments - The arguments to be replaced in the message. They will replace {} placeholders in the order they are passed.throwable - The exception associated with the debug log message.public void error(String message, Object... arguments)
Writes an error log message to the console. Error log messages provide information about unrecoverable events in the application flow.
error in interface com.groupdocs.foundation.logging.ILoggermessage - The error log message.arguments - The arguments to be replaced in the message. They will replace {} placeholders in the order they are passed.public void error(Throwable throwable, String message, Object... arguments)
Writes an error log message to the console. Error log messages provide information about unrecoverable events in the application flow.
error in interface com.groupdocs.foundation.logging.ILoggerthrowable - The exception associated with the error log message.message - The error log message.arguments - The arguments to be replaced in the message. They will replace {} placeholders in the order they are passed.public boolean isDebugEnabled()
Checks if the debug level is enabled for logging.
isDebugEnabled in interface com.groupdocs.foundation.logging.ILoggertrue if the debug level is enabled, false otherwise.public boolean isErrorEnabled()
isErrorEnabled in interface com.groupdocs.foundation.logging.ILoggertrue if error-level logging is enabled, false otherwise.public boolean isTraceEnabled()
Checks if the trace level is enabled for logging.
isTraceEnabled in interface com.groupdocs.foundation.logging.ILoggertrue if the trace level is enabled, false otherwise.public boolean isWarningEnabled()
Checks if the warning level is enabled for logging.
isWarningEnabled in interface com.groupdocs.foundation.logging.ILoggertrue if the warning level is enabled, false otherwise.public void trace(String message, Object... arguments)
Writes a trace message to the console. Trace log messages provide generally useful information about application flow.
trace in interface com.groupdocs.foundation.logging.ILoggermessage - The trace message.arguments - The arguments to be replaced in the message. They will replace {} placeholders in order of passing.public void trace(Throwable throwable, String message, Object... arguments)
Writes a trace log message to the console. Trace log messages provide generally useful information about the application flow.
trace in interface com.groupdocs.foundation.logging.ILoggerthrowable - The exception associated with the trace log message.message - The trace log message.arguments - The arguments to be replaced in the message. They will replace {} placeholders in the order they are passed.public void warning(String message, Object... arguments)
Writes a warning log message to the console. Warning log messages provide information about unexpected and recoverable events in the application flow.
warning in interface com.groupdocs.foundation.logging.ILoggermessage - The warning log message.arguments - The arguments to be replaced in the message. They will replace {} placeholders in the order they are passed.public void warning(Throwable throwable, String message, Object... arguments)
Writes a warning log message to the console. Warning log messages provide information about unexpected and recoverable events in the application flow.
warning in interface com.groupdocs.foundation.logging.ILoggerthrowable - The exception associated with the warning log message.message - The warning log message.arguments - The arguments to be replaced in the message. They will replace {} placeholders in the order they are passed.Copyright © 2025. All rights reserved.