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 LOGGING_CONFIG_PATH environment variable before starting BaseModel:

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

Or pass it when launching the container:

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

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.