Logging Backends

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

Backend Configuration

SciMLLogging.set_logging_backendFunction
`set_logging_backend(backend::String)``

Set the logging backend preference. Valid options are:

  • "logging": Use Julia's standard Logging system (default)
  • "core": Use Core.println for simple output

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

Core Backend

Uses Core.println for direct console output. Simpler but less flexible. This allows messages to emitted, while still being compatible with static compilation and JuliaC.

SciMLLogger

SciMLLogging.SciMLLoggerFunction
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 REPL
  • info_repl = true: Show info messages in REPL
  • warn_repl = true: Show warnings in REPL
  • error_repl = true: Show errors in REPL
  • 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
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