First Stab at a BoxLang Log Viewer
Briefly

First Stab at a BoxLang Log Viewer
"My initial attempt made use of the fact that BoxLang code can get access to the current runtime via getBoxRuntime(). The docs for this function are a bit sparse, but that's mostly because the object returned from this is an instance of the Java class. This link, https://apidocs.ortussolutions.com/boxlang/latest.html, will take you to the latest Java source for BoxLang. From there, you can dig down to the BoxRuntime class and start looking into the various available methods."
"This worked, but Brad Wood had some interesting comments about this use case. He mentioned (and if I misspeak, blame me, not him), that it's better to get the current Box context instead. He mentioned that configuration could be changed based on how it's being run, and while unlikely, this version was safer: public function getLogDirectory() { // below per advice from Brad return getBoxContext().getConfig().logging.logsDirectory; }"
A simple web application was built to quickly view logs in a browser as an alternative to tailing logs in a terminal. The application requires a dynamic method to locate log files across environments. BoxLang provides API access to runtime and context configuration values. One approach retrieves the logs directory via getBoxRuntime().getConfiguration().asStruct().logging.logsDirectory. A recommended, safer approach uses getBoxContext().getConfig().logging.logsDirectory because configuration can vary depending on execution context. Example code snippets demonstrate both methods and explain the rationale for preferring Box context access.
Read at Raymondcamden
Unable to calculate read time
[
|
]