Class Log4j2Log
- All Implemented Interfaces:
LogInterface
LogInterface that routes every message to
Apache Log4j 2. This lets
MCPDBWizard software — and the JDBC code the wizard generates — log through a Log4j 2
configuration the host application already owns, instead of MCPDBWizard's own file/console logs.
The five LogInterface severities map onto Log4j 2 levels as follows. Because Log4j 2
has a dedicated FATAL level, syserror (reserved for "really bad and never
supposed to happen") is distinguished from ordinary error:
LogInterface | Log4j 2 |
|---|---|
debug | DEBUG |
info | INFO |
warning | WARN |
error | ERROR |
syserror | FATAL |
The isModal and isLogged flags carried by the detailed LogInterface
methods are accepted and ignored: Log4j 2 has no modal-dialog concept, and whether a message is
actually written is decided by the configured Log4j 2 level filtering, not by this class. Debug
messages additionally honour GenericLog.debugOn() / GenericLog.debugOff() (off by default), matching
the other LogInterface implementations.
The exception-taking error/syserror methods pass the Throwable straight
to Log4j 2, so the backend records the full stack trace rather than just the message text.
This backend depends only on the Log4j 2 API (log4j-api); the host application supplies
the Log4j 2 core implementation and its configuration.
See LogInterface
Copyright 2003-2026 ATB Consultancy Services Ltd (formerly Orinda Software Ltd, Dublin, Ireland)
- Version:
- 7
- Author:
- devteam@mcpdbwizard.com
-
Field Summary
Fields inherited from class com.mcpdbwizard.pub.GenericLog
autoFlush, autoLog, debugMessagesPrinted, LOG_BEING_FLUSHED, printThreadIdFields inherited from interface com.mcpdbwizard.pub.LogInterface
DEBUG, DEFAULT_FIELD_DELIMITER, DEFAULT_FILENAME_DAY_FORMAT, DEFAULT_FILENAME_TIME_FORMAT, DEFAULT_TIME_FORMAT_STRING, ERROR, INFO, SYSERR, WARN -
Constructor Summary
ConstructorsConstructorDescriptionCreate an instance ofLog4j2Logbacked by a logger named after this class.Create an instance ofLog4j2Logbacked by a logger named after the given class.Create an instance ofLog4j2Logbacked by a logger with the given name. -
Method Summary
Modifier and TypeMethodDescriptionvoidLog an error, passing the exception to Log4j 2 so the full stack trace is recorded.voidflush()Required byLogInterfacebut not used: Log4j 2 manages its own buffering and flushing.Returns the name of the Log4j 2 logger messages are routed through.voidLog a serious error atFATAL, passing the exception to Log4j 2 so the full stack trace is recorded.protected voidwriteMessage(String messageType, String messageText, boolean isModal, boolean isLogged) Route a formatted message to the Log4j 2 level that corresponds to its severity.Methods inherited from class com.mcpdbwizard.pub.GenericLog
debug, debug, debugOff, debugOn, error, error, error, formatMessage, getDateFormat, getDebug, info, info, setAutoFlush, setAutoLog, syserror, syserror, syserror, warning, warningMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.mcpdbwizard.pub.LogInterface
debug, debug, debugOff, debugOn, error, error, error, getDateFormat, getDebug, info, info, setAutoFlush, setAutoLog, syserror, syserror, syserror, warning, warning
-
Constructor Details
-
Log4j2Log
public Log4j2Log()Create an instance ofLog4j2Logbacked by a logger named after this class. -
Log4j2Log
Create an instance ofLog4j2Logbacked by a logger with the given name.- Parameters:
loggerName- the Log4j 2 logger name to use (for example a fully qualified class name or a functional category).
-
Log4j2Log
Create an instance ofLog4j2Logbacked by a logger named after the given class.- Parameters:
clazz- the class whose name is used as the Log4j 2 logger name.
-
-
Method Details
-
writeMessage
protected void writeMessage(String messageType, String messageText, boolean isModal, boolean isLogged) Route a formatted message to the Log4j 2 level that corresponds to its severity. Log4j 2 applies its own level filtering, so a message emitted here may still be discarded downstream.- Specified by:
writeMessagein classGenericLog- Parameters:
messageType- one of theDEBUG,INFO,WARN,ERRORorSYSERRconstants defined inLogInterface.messageText- the message text.isModal- ignored; Log4j 2 has no modal-dialog concept.isLogged- ignored; the configured Log4j 2 level filtering decides what is written.
-
error
Log an error, passing the exception to Log4j 2 so the full stack trace is recorded.- Specified by:
errorin interfaceLogInterface- Overrides:
errorin classGenericLog- Parameters:
theException- the exception to log.isModal- ignored; Log4j 2 has no modal-dialog concept.isLogged- ignored; the configured Log4j 2 level filtering decides what is written.
-
syserror
Log a serious error atFATAL, passing the exception to Log4j 2 so the full stack trace is recorded.- Specified by:
syserrorin interfaceLogInterface- Overrides:
syserrorin classGenericLog- Parameters:
theException- the exception to log.isModal- ignored; Log4j 2 has no modal-dialog concept.isLogged- ignored; the configured Log4j 2 level filtering decides what is written.
-
flush
public void flush()Required byLogInterfacebut not used: Log4j 2 manages its own buffering and flushing.- Specified by:
flushin interfaceLogInterface- Specified by:
flushin classGenericLog
-
getCurrentLog
Returns the name of the Log4j 2 logger messages are routed through.- Specified by:
getCurrentLogin interfaceLogInterface- Specified by:
getCurrentLogin classGenericLog- Returns:
- the Log4j 2 logger name (not a file path; the actual destination is determined by the Log4j 2 configuration).
-