Use the logging utility from the JS SDK

Search JS SDK for React offers a logging utility that you can use during development. You can monitor data requests and responses, and also watch values while debugging in development.

To use the logging utility to print everything and debug:

  • In the root of your application, to instantiate the logging utility, outside the WidgetsProvider wrapper, paste the following code block:

    RequestResponse
    import { Logger } from 'sitecore-search/react';
    
    Logger.setLogLevel(Logger.DEBUG);
    Tip

    Use an environment variable as the value for the Logger level and to prevent tracing in production, set it to Logger.NONE for production.

    The setLogLevel function accepts enum values.

Do you have some feedback for us?

If you have suggestions for improving this article,