# Debugging

Learn how to debug your integration.

If you are experiencing issues with your integration, there are a few things you can do to diagnose the problem.

> **Need help?**
>
> If you have any questions, please [contact us](https://croct.com/contact/support) for assistance or join our [community](https://croct.link/community) to get help from our team and other users.

## Enable logging

The SDK reports internal failures through a [PSR-3](https://www.php-fig.org/psr/psr-3/) logger. Provide one [when you create the SDK](../api/core/croct/plug) to capture what happens during a request:

```php
<?php
use Croct\Plug\Croct;
use Croct\Plug\CookieStorage;

$croct = Croct::plug(
    appId: 'APPLICATION_ID',
    apiKey: 'API_KEY',
    storage: CookieStorage::fromGlobals(),
    logger: $logger,
);
```

The logged messages help you detect and diagnose issues such as failed requests or misconfiguration.

## Enable debug mode

To debug the [client-side SDK](../client-side-setup), enable debug mode when you create the SDK:

```php
<?php
use Croct\Plug\Croct;
use Croct\Plug\CookieStorage;

$croct = Croct::plug(
    appId: 'APPLICATION_ID',
    apiKey: 'API_KEY',
    storage: CookieStorage::fromGlobals(),
    debug: true,
);
```

The flag is forwarded to the browser, where the SDK logs detailed information to the console. See [Debugging](/reference/sdk/javascript/troubleshooting/debugging#enable-debug-mode) in the JavaScript SDK reference for the details.

## Inspect the errors

When a request fails and no fallback is set, the SDK throws an [exception](../api/exceptions/croct-exception). Catch it to log or inspect the failure:

```php
<?php
use Croct\Plug\Croct;
use Croct\Plug\Exception\CroctException;

$croct = Croct::fromDotenv();

try {
    $content = $croct->fetchContent('home-hero')->getContent();
} catch (CroctException $error) {
    error_log('Croct error: ' . $error->getMessage());
}
```

For resilience, provide a [fallback](../content-rendering#fault-tolerance) so personalization failures never break your application.
