===== Logging Formats ===== ~~NOTOC~~ == See Also == [[v6:logging|The Logging Main Page]] [[v6:logging:custom_formats|Customizing the message JSON]] The logging plugin produces output in 2 different formats, a classic text message and a JSON encoded string. The example shown below is for the same event but in the 2 different formats. -------------------------------------- - The date and time. Note that if the monolog plugin is used then the time includes microseconds - The logging tag - The logging level - The log message - Additional tags if the monolog plugin is used ==== Plain Text Format ==== ''[2023-12-30T12:06:33.954984-07:00] ADODB.CRITICAL: Execution of statement failed: SELECT COUNT(*) FROM employee , / Error: 1146 Table 'employees.employee' doesn't exist [] []'' ==== JSON Format ==== [2023-12-30T12:09:44.054087-07:00] ADODB.CRITICAL: { "version":"1.0", "ADOdbVersion":"v5.23.0-dev Unreleased", "level":"500", "shortMessage":"QUERY EXECUTION FAILURE", "sqlStatement": { "sql":"SELECT COUNT(*) FROM employex", "params":false }, "errorCode":1146, "errorMessage":"Table 'employees.employex' doesn't exist", "metaErrorCode":-18, "metaErrorMessage":"no such table", "callStack":"", "host":"WINDOWS-11", "source":"cli", "driver":"mysqli", "php":"8.0.30", "os":"WINNT" } === The Call Stack === If the ''$logBacktrace'' flag is set, then the "callStack" element of the JSON message contains an array of stack calls that identify the source and path of the error: [{ "class":"ADOConnection", "function":{ "name":"_Execute", "args":["SELECT COUNT(*) FROM employeex"] }, "file":"C:\/dev\/github\/ADOdb\/drivers\/adodb-mysqli.inc.php", "line":1089 },{ "class":"ADODB_mysqli", "function":{ "name":"execute", "args":["SELECT COUNT(*) FROM employeex"] }, "file":"C:\/dev\/github\/ADOdb\/drivers\/adodb-mysqli.inc.php", "line":301 },{ "class":"ADODB_mysqli", "function":{ "name":"GetOne", "args":["SELECT COUNT(*) FROM employeex"] }, "file":"C:\/dev\/tests\/monolog.php", "line":59 }] ==== Monolog Logging Tags ==== If the monolog plugin is used, then additional tags can be appended to the message as a JSON encoded array. These tags can be used in log management software for filtering purposes. In addition to any custom tags, the plugin can add a set of pre-defined system tags that describe the ADOdb installation using the ''setMessageTags()'' method. These tags can be added to both plain-text and JSON format messages. { "host":"WINDOWS-11", "source":"cli", "driver":"mysqli", "php":"8.0.30", "os":"WINNT", "ADOdbVersion":"5.23.0-dev" } Any other custom tags are appended to the base as a simple key -> value pair using the ''setMessageTag()'' method: { "environment":"PRODUCTION" }