Skip to main content
Skip table of contents

Code logs

Code logs can help troubleshoot a code-service. They also offer a way to profile how long certain sections of code take.

To use code logs, first they have to be enabled environment-wide by setting these config parameters:

  1. LeanMode false

  2. StoreCodeLogs true

From this point on code logs will be stored for any newly run microservice or newly restarted stream / preloaded service.

To view code logs, do one of the following:

  1. Check the Logs checkbox in the service’s Code Editor tab…

    image-20250512-202326.png

  2. …OR turn on the Logging toggle switch for the service in the Code page…

    image-20250512-202603.png

  3. Set the MINIMUM log level for the service. Choose between these. Note that DEBUG is most permissive and ERROR is least permissive:

    image-20250512-203707.png
    1. DEBUG

    2. INFO

    3. WARN

    4. ERROR

  4. Now choose from the following to add log statements to your code. Based on the minimum log-level set, the log statement may or may not cause a log to be added. For example, if the minimum log level is WARN then only console.warn(…), console.error(…) and console.alert(…) will cause logs to be written:

    1. console.debug(message?: any, …optionalParams: any[])

    2. console.info(message?: any, …optionalParams: any[])

      1. equivalent to console.log(message?: any, …optionalParams: any[])

      2. equivalent to log(message?: any, …optionalParams: any[]) - NOT RECOMMENDED!!! This old function for logging is included for completeness. Please use console.log… or console.info… instead.

    3. console.warn(message?: any, …optionalParams: any[])

    4. console.error(message?: any, …optionalParams: any[])

    5. console.alert(message?: any, …optionalParams: any[])

  5. These are valid examples of log statements:

    1. console.warn(“Log Prefix”);

    2. console.debug(req);

    3. console.alert(“Log Prefix”, req, “Log Suffix”, { blah: 123 });

  6. Note in this service, the console.debug(…) does NOT write a log but the console.error(…) and console.alert(…) DO. This is because the minimum log level is set to WARN:

    image-20250512-204640.png

  7. Logs appear to the right of the code in the Code Editor page. Individual logs can be deleted by clicking the trash can icon next to an individual log…

    image-20250512-204821.png

    …or an individual log can be selected, viewed, searched inside…

    image-20250512-204918.png

  8. Note that there may be several log entries if there are several instances of the service (e.g. with auto-balanced stream-services).

  9. All logs for the service can be selected, viewed, searched by clicking the View all logs icon…

    image-20250512-205118.png
    image-20250512-205129.png

  10. Note that logs don’t appear immediately after a console… or log statement executes. Note the Refresh most recent runs icon…

    image-20250512-205258.png

  11. To delete ALL logs for a service click the Delete all logs icon and confirm.

    image-20250512-205343.png

  12. To view and search for logs across all services in the system use the Logs page:

    image-20250512-205439.png
JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.