Skip to content

Built-in Logging

By default BaseModel streams logs to the console at INFO level. For production runs or debugging you can redirect output to files, adjust verbosity, or separate error logs — all by pointing to a custom config file.

Custom Logging Config

Create a YAML file using Python's logging dict schema and set the MONAD_LOGGING_CONFIG_PATH environment variable before starting BaseModel:

bash
export MONAD_LOGGING_CONFIG_PATH=/path/to/logging_config.yaml

Or pass it when launching the container:

bash
docker run -it \
  -e MONAD_LOGGING_CONFIG_PATH=/basemodel/logging_config.yaml \
  --gpus all --shm-size 64gb \
  -v /your/basemodel/folder:/basemodel:z \
  REGISTRY_URL/monad:VERSION

Renamed in monad 1.11

The logging environment variables are namespaced under MONAD_LOGGING_* as of monad 1.11.0. MONAD_LOGGING_CONFIG_PATH replaces the former LOGGING_CONFIG_PATH — update any scripts that set the old name.

Log Output Directory

By default BaseModel writes its log files (including an aggregate full.log) next to the run, using the paths baked into the image's logging config. When the container runs under an arbitrary or non-root UID — or the default location is read-only — file logging can fail with LoggingSetupError: Cannot create or write the log directory.

Set MONAD_LOGGING_DIRECTORY to a writable, mounted path to redirect all log files there:

bash
docker run -it \
  -e MONAD_LOGGING_DIRECTORY=/basemodel/logs \
  --gpus all --shm-size 64gb \
  -v /your/basemodel/folder:/basemodel:z \
  REGISTRY_URL/monad:VERSION

Leaving it unset (or blank) keeps the default filenames from the logging config.

Example Config

The config below keeps the default console output and adds two rotating file handlers — one for general logs and one for errors only:

YAML
version: 1
formatters:
  default:
    format: "%(asctime)s - %(levelname)8s - %(name)s: %(message)s"
    datefmt: "%Y-%m-%d %H:%M:%S"

handlers:
  console:
    class: logging.StreamHandler
    level: INFO
    formatter: default
    stream: ext://sys.stdout
  mainFile:
    class: logging.FileHandler
    level: INFO
    formatter: default
    filename: logs/main.log
    mode: a
  errorFile:
    class: logging.FileHandler
    level: ERROR
    formatter: default
    filename: logs/error.log
    mode: a

loggers:
  monad:
    level: INFO
    handlers: [console, mainFile, errorFile]
    propagate: False

root:
  level: WARNING
  handlers: []

Key points:

  • monad logger — captures all BaseModel output. Set its level to DEBUG for verbose diagnostics or WARNING to silence routine messages.
  • root logger — catches everything else (third-party libraries). Keep at WARNING or higher to avoid noise.
  • File handlersmainFile records the full run log; errorFile isolates errors for quick scanning. Create the logs/ directory before training starts, or use absolute paths.