Debug Logging in Content SDK Apps — A Developer’s Guide
When building headless applications with Sitecore Content SDK, debugging becomes crucial especially as your component structure and data dependencies grow. Instead of writing console.log everywhere, the Content SDK provides a much cleaner and controlled approach to logging. The SDK uses the popular debug module for displaying debugging information. This allows developers to enable or disable logging dynamically using environment variables, making it easier to troubleshoot issues without modifying code. Debug logging is disabled by default, keeping terminal noise to a minimum during normal development. Once you need insights into what the Content SDK is doing—just turn it on! Enabling Debug Logs Use the DEBUG environment variable to control what logs are shown. When logging is enabled and you run your application, all triggered instances of debug() relevant to the namespaces you choose to include will be displayed in your console. To enable ...