Logging Backends

SciMLLogging supports two output backends: Julia's standard logging system (default) and simple console output.

Backend Configuration

SciMLLogging.set_logging_backend — Function
set_logging_backend(backend::String)

Set the logging backend preference.

Arguments

  • backend: Backend name. Valid values are "logging", "core", and "tracy".

Returns

Returns nothing after updating the preference, or throws ArgumentError for an invalid backend.

Note: You must restart Julia for this preference change to take effect.

source

Switch between backends:

# Switch to simple console output
set_logging_backend("core")

# Switch back to standard logging (default)
set_logging_backend("logging")

Note: Restart Julia after changing backends.

Standard Logging Backend

Uses Julia's Logging system. Messages integrate with loggers and can be filtered or redirected using standard filters or other packages that integrate with the logging system, e.g. LoggingExtras.jl.

using Logging

# Route to console
with_logger(ConsoleLogger(stdout, Logging.Info)) do
    result = solve(problem, verbose = SolverVerbosity(Standard()))
end

# Route to file
open("output.log", "w") do io
    with_logger(SimpleLogger(io)) do
        result = solve(problem, verbose = SolverVerbosity(Detailed()))
    end
end

Console Output Backend

Uses Julia's public println function for direct console output. It is simpler but less flexible than the standard logging backend, while remaining compatible with static compilation and JuliaC.

SciMLLogger

SciMLLogging.SciMLLogger — Function
SciMLLogger(; kwargs...)

Create a logger that routes messages to REPL and/or files based on log level.

Keyword Arguments

  • debug_repl = false: Show debug messages in the current logger.
  • info_repl = true: Show info messages in the current logger.
  • warn_repl = true: Show warnings in the current logger.
  • error_repl = true: Show errors in the current logger.
  • debug_file = nothing: File path for debug messages.
  • info_file = nothing: File path for info messages.
  • warn_file = nothing: File path for warnings.
  • error_file = nothing: File path for errors.

Returns

A LoggingExtras.TeeLogger that routes each log level to the requested sinks.

source

Convenient logger that routes messages by level:

# Route info to file, warnings/errors to console and file
logger = SciMLLogger(
    info_repl = false,
    info_file = "info.log",
    warn_file = "warnings.log",
    error_file = "errors.log"
)

with_logger(logger) do
    result = solve(problem, verbose = SolverVerbosity(Standard()))
end