LoggingMiddleware
Audit lifecycle events with configurable file and console logging
Class: bxModules.bxai.models.middleware.core.LoggingMiddleware
Logs agent, LLM, and tool lifecycle events to the ai log and optionally to stdout.
Features
Logs
beforeAgentRunandafterAgentRunLogs
beforeLLMCallandafterLLMCallLogs
beforeToolCallandafterToolCallLogs
onErrorwith phase and error messageSupports log prefix and log level
Constructor
middleware = new bxModules.bxai.models.middleware.core.LoggingMiddleware(
logToFile : true,
logToConsole : false,
logLevel : "info",
prefix : "[AI Middleware]"
)Configuration
logToFile
boolean
true
Write events to BoxLang log ai
logToConsole
boolean
false
Also print events to stdout
logLevel
string
"info"
Base level for emitted messages
prefix
string
"[AI Middleware]"
Prefix prepended to each line
Hooks Used
beforeAgentRunafterAgentRunbeforeLLMCallafterLLMCallbeforeToolCallafterToolCallonError
Example
Notes
onErrorlogs with levelerrorand then returnscontinue().Message content is truncated in emitted text for readability.
Last updated