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. 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.
SciMLLogging.get_logging_backend — Function`get_logging_backend()`Get the current logging backend preference.
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
endCore 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.SciMLLogger — FunctionSciMLLogger(; 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 REPLinfo_repl = true: Show info messages in REPLwarn_repl = true: Show warnings in REPLerror_repl = true: Show errors in REPLdebug_file = nothing: File path for debug messagesinfo_file = nothing: File path for info messageswarn_file = nothing: File path for warningserror_file = nothing: File path for errors
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