Class Slf4jLog

java.lang.Object
com.mcpdbwizard.pub.GenericLog
com.mcpdbwizard.pub.Slf4jLog
All Implemented Interfaces:
LogInterface

public class Slf4jLog extends GenericLog implements LogInterface
An implementation of LogInterface that routes every message to SLF4J (the Simple Logging Facade for Java). This lets MCPDBWizard software — and the JDBC code the wizard generates — log through whatever SLF4J binding the host application already uses (Logback, Log4j 2, java.util.logging, and so on) instead of MCPDBWizard's own file/console logs.

The five LogInterface severities map onto SLF4J levels as follows:

LogInterface severity to SLF4J level mapping
LogInterfaceSLF4J
debugDEBUG
infoINFO
warningWARN
errorERROR
syserrorERROR

The isModal and isLogged flags carried by the detailed LogInterface methods are accepted and ignored: SLF4J has no modal-dialog concept, and whether a message is actually written is decided by the configured SLF4J backend's 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 SLF4J, so the backend records the full stack trace rather than just the message text.

See LogInterface

Copyright 2003-2026 ATB Consultancy Services Ltd (formerly Orinda Software Ltd, Dublin, Ireland)

Version:
7
Author:
[email protected]
  • Constructor Details

    • Slf4jLog

      public Slf4jLog()
      Create an instance of Slf4jLog backed by a logger named after this class.
    • Slf4jLog

      public Slf4jLog(String loggerName)
      Create an instance of Slf4jLog backed by a logger with the given name.
      Parameters:
      loggerName - the SLF4J logger name to use (for example a fully qualified class name or a functional category).
    • Slf4jLog

      public Slf4jLog(Class<?> clazz)
      Create an instance of Slf4jLog backed by a logger named after the given class.
      Parameters:
      clazz - the class whose name is used as the SLF4J logger name.
  • Method Details

    • writeMessage

      protected void writeMessage(String messageType, String messageText, boolean isModal, boolean isLogged)
      Route a formatted message to the SLF4J level that corresponds to its severity. The SLF4J backend applies its own level filtering, so a message emitted here may still be discarded downstream.
      Specified by:
      writeMessage in class GenericLog
      Parameters:
      messageType - one of the DEBUG, INFO, WARN, ERROR or SYSERR constants defined in LogInterface.
      messageText - the message text.
      isModal - ignored; SLF4J has no modal-dialog concept.
      isLogged - ignored; the configured SLF4J backend decides what is written.
    • error

      public void error(Exception theException, boolean isModal, boolean isLogged)
      Log an error, passing the exception to SLF4J so the full stack trace is recorded.
      Specified by:
      error in interface LogInterface
      Overrides:
      error in class GenericLog
      Parameters:
      theException - the exception to log.
      isModal - ignored; SLF4J has no modal-dialog concept.
      isLogged - ignored; the configured SLF4J backend decides what is written.
    • syserror

      public void syserror(Exception theException, boolean isModal, boolean isLogged)
      Log a serious error, passing the exception to SLF4J so the full stack trace is recorded.
      Specified by:
      syserror in interface LogInterface
      Overrides:
      syserror in class GenericLog
      Parameters:
      theException - the exception to log.
      isModal - ignored; SLF4J has no modal-dialog concept.
      isLogged - ignored; the configured SLF4J backend decides what is written.
    • flush

      public void flush()
      Required by LogInterface but not used: SLF4J backends manage their own buffering and flushing.
      Specified by:
      flush in interface LogInterface
      Specified by:
      flush in class GenericLog
    • getCurrentLog

      public String getCurrentLog()
      Returns the name of the SLF4J logger messages are routed through.
      Specified by:
      getCurrentLog in interface LogInterface
      Specified by:
      getCurrentLog in class GenericLog
      Returns:
      the SLF4J logger name (not a file path; the actual destination is determined by the SLF4J backend's configuration).