> ## Documentation Index
> Fetch the complete documentation index at: https://documentation.idenfy.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Android SDK Logging and Webhooks

> Handle iDenfy Android SDK callbacks, lifecycle event logging, and verification event tracking using the logging handler and listeners.

## Logging

The SDK provides a way to log user and SDK common actions (lifecycle events, navigation, camera changes). This can be useful for understanding specific scenarios or troubleshooting potential issues.

To enable logging, provide your implementation of the **IdenfyLoggingHandlerUseCase** class:

```kotlin theme={"system"}
  val consoleLogging = ConsoleLoggingImpl()
  IdenfyController.getInstance().idenfyLoggingHandler = IdenfyLoggingHandlerUseCaseImpl(consoleLogging)
```

```kotlin theme={"system"}
  class ConsoleLoggingImpl {
    fun log(event: String, message: String, token: String) {
        Log.d("fromIdenfySDK-$event", message)
    }
}
```

```kotlin theme={"system"}
 class IdenfyLoggingHandlerUseCaseImpl(private var consoleLoggingImpl: ConsoleLoggingImpl):IdenfyLoggingHandlerUseCase {
    override fun logEvent(event: String, message: String, token: String) {
        consoleLoggingImpl.log(event, message, token)
    }
}
```

You only need to provide a concrete implementation of the **IdenfyLoggingHandlerUseCase** interface.

If you also want to see OkHttp requests/responses and payload in **Logcat**, initialize the iDenfy SDK with `IdenfySDKLoggingEnum.FULL`:

```kotlin theme={"system"}
val idenfySettingsV2 = IdenfySettingsV2.IdenfyBuilderV2()
                .withAuthToken(authToken)
                .withLogging(IdenfySDKLoggingEnum.FULL)
                .build()
```

## User Events Webhooks (Optional)

The SDK provides webhooks about events occurring throughout the verification process. Results are delivered while the verification process is active and the application is presenting SDK views.

### Declare a Class for Receiving Events

Declare a class that implements `IdenfyUserFlowHandler` to call your backend service, log events, or apply changes:

```kotlin theme={"system"}
class IdenfyUserFlowCallbacksHandler : IdenfyUserFlowHandler {
    /**
     * @param documentType Selected document type
     */
    override fun onDocumentSelected(documentType: String) {
        Log.d("onDocumentSelected", documentType)
    }

    /**
     * @param issuingCountryCode Selected issuingCountryCode
     */
    override fun onCountrySelected(issuingCountryCode: String) {
        Log.d("onCountrySelected", issuingCountryCode)
    }

    /**
     * @param photosUploaded indicated that photos have been uploaded
     */
    override fun onPhotosUploaded(photosUploaded: Boolean) {
        Log.d("onPhotosUploaded", photosUploaded.toString())
    }

    /**
     * @param processingStarted indicates that processing has started
     */
    override fun onProcessingStarted(processingStarted: Boolean) {
        Log.d("onProcessingStarted", processingStarted.toString())
    }
}
```

### Configure Application Class

Set `IdenfyUserFlowController` to reference `idenfyUserFlowCallbacksHandler` in the application class:

```kotlin theme={"system"}
class IdenfyApplication : MultiDexApplication() {
    override fun onCreate() {
        super.onCreate()
        val idenfyUserFlowCallbacksHandler =
            IdenfyUserFlowCallbacksHandler()
        IdenfyUserFlowController.setIdenfyUserFlowHandler(idenfyUserFlowCallbacksHandler)
    }
}
```

<Note>
  You must set the webhooks handler in the **application** class to ensure that the listener is set again after the application process has stopped.
</Note>
