Change an Application’s Log Level
You might sometimes want to change the app’s log level to change output in the browser console. For example, the default info log level for console messages may be useful during development stages, but once the app goes into production, you might want to reduce console output to only critical information.
-
To change an application’s log level:
-
On the Web Apps tab in the Navigator, select your web app, then click the JSON tab to open the
app-flow.jsonfile. Alternatively, switch to the app’s Source view and locate theapp-flow.jsonfile underwebApps. -
Add the
logConfigsnippet to the file:"logConfig": { "level": "*`loglevel`*" },where
loglevelcan be warn, error, info, fine, or finer. For example:"logConfig": { "level": "error" },You can also use an expression. For example, if you’ve defined
window.myConfigas a global variable, you can define the log level as:"logConfig": { "level": "{{window.myConfig?.VB_LOGCONFIG_LEVEL ? window.myConfig.VB_LOGCONFIG_LEVEL : 'error'}}" },where the log level is
window.myConfig.VB_LOGCONFIG_LEVEL’s value. Ifwindow.myConfig.VB_LOGCONFIG_LEVELisn’t defined, the log level is set aserror.
-
-
Run your app and view output in the browser’s console.
-
It’s also possible to dynamically set the app’s runtime log level in your browser’s current session to temporarily troubleshoot issues. You do this using the
globalThis.vbInitConfig.LOG.levelproperty in your browser’s console. Here’s how to do this in Chrome:-
Open Chrome DevTools.
-
Click the Console tab.
-
Enter the following command in the console:
globalThis.vbInitConfig.LOG.level = '*`loglevel`*'where
loglevelcan be none (least verbose), error, warn, info, or finer (most verbose). The ideal level is info, which is a good balance between least and most verbose. For example:globalThis.vbInitConfig.LOG.level = 'info' -
To dynamically set the log level for JET elements, you use the
sessionStorage.setItem()call in your browser’s console.This setting requires your application to be on JET 14.0.6 or higher. Check the Settings editor to make sure your app uses a supported version. Upgrade your app, if needed.
Enter the following command in the console:
sessionStorage.setItem('ojet.logLevel', '*`loglevel`*')where
loglevelcan be none (least verbose), error, warning, info, or log (most verbose). For example:sessionStorage.setItem('ojet.logLevel', 'error')
-
Note:
If the JET log level is set to info and the runtime log level is set to error, JET logs will not show. You must use the same value for runtime and JET logging to see both logs.
5. Refresh your browser to view updated information in the console.
6. To reset the log level for your browser's current session, enter `sessionStorage.removeItem("vbSessionLog")` for runtime logs and `sessionStorage.removeItem("ojet.logLevel")` for JET logs in the console, then refresh your browser.