Class LogBackends

java.lang.Object
com.mcpdbwizard.pub.LogBackends

public final class LogBackends extends Object
Lets the deployment override the logging backend the generator chose.

DAO_LOG_TYPE is a generation-time setting for a deployment-time concern. When this tool was written those were the same moment: one person generated the code and put the jar on a server. One config is now run in a container, over stdio, through the web Runtime page or standalone, and the right backend differs for each — Console Log is fine on a desktop and corrupts the protocol stream on stdio; Text Log writes to a disk that vanishes with the container; SLF4J needs a binding the image may not carry.

So OB_LOG_BACKEND names a backend at run time, and the generated choice becomes the default rather than the only answer. Set nothing and behaviour is exactly as before.

Deliberately not called DAO_LOG_TYPE

There is already one setting in this project that is both a config flag and an environment variable — MCP_HTTP_TOKEN — and CLAUDE.md records it as "the confusing case" that catches people out. Repeating that knowingly would be indefensible, so the override has a name of its own and the two can never be mistaken for each other.

A bad value stops the program

An unusable OB_LOG_BACKEND throws rather than quietly falling back to the generated default. Falling back would produce the exact failure this class exists to prevent: an operator who believes they redirected the logs and did not. That matches McpAuditSinks, which refuses to start rather than leave a server silently unaudited.

Accepts either a short name — console, jul, text, slf4j, log4j2 — or the fully-qualified class name of any LogInterface. A custom class needs a public constructor taking two strings, one string, or nothing; they are tried in that order, which is what lets one variable drive TextLog(directory, name) and ConsoleLog() alike. Copyright 2003-2026 ATB Consultancy Services Ltd (formerly Orinda Software Ltd, Dublin, Ireland)

  • Field Details

    • BACKEND_VARIABLE

      public static final String BACKEND_VARIABLE
      Names the backend to use, overriding the one baked in at generation time.
      See Also:
    • LEGACY_BACKEND_VARIABLE

      public static final String LEGACY_BACKEND_VARIABLE
      The pre-rename spelling, still honoured when BACKEND_VARIABLE is unset.

      OB_ was for OrindaBuild. This variable is read by the pub library, which ships inside customers' deployments — it is set in their container environments and start scripts, not in this repository, so a clean break could not be fixed by editing this tree. Its failure mode is quiet, too: an unrecognised variable is indistinguishable from an unset one, so the deployment silently reverts to whatever backend was baked in at generation time and the operator's logs go somewhere else without a word.

      See Also:
  • Method Details

    • fromEnvironment

      public static LogInterface fromEnvironment(String theLogName, String theSecondName)
      The overriding backend, or null when none is configured.

      Returning null rather than taking the default as an argument is deliberate: the generated code constructs its default only if this returns nothing, so a TextLog default does not open a log file that is then thrown away.

      Parameters:
      theLogName - the generated log name — a logger name, or a directory for a file backend
      theSecondName - the second constructor argument a two-argument backend needs, usually the factory class name; may be null
      Returns:
      the backend named by MCPDBWIZARD_LOG_BACKEND (or the legacy OB_LOG_BACKEND), or null to use the generated default
      Throws:
      IllegalStateException - if the variable names something unusable