# Native Android Implement logging and error handling for Fordefi's Native Android SDK. ## Add logging To receive logs from the SDK, you can create your own class implementing the interface `IFordefiLogger`, and calling the function `setLogger` with the instance of this class. ```kotlin import com.fordefi.fordefi.FordefiLogLevel import com.fordefi.fordefi.IFordefiLogger class MyFordefiLogger: IFordefiLogger { override fun log(logLevel: FordefiLogLevel, message: String) { when(logLevel) { FordefiLogLevel.Verbose -> Log.v("FordefiSDK", message) FordefiLogLevel.Info -> Log.i("FordefiSDK", message) FordefiLogLevel.Warning -> Log.w("FordefiSDK", message) FordefiLogLevel.Error -> Log.i("FordefiSDK", message) } } } class MainActivity: ComponentActivity() { private val logger = MyFordefiLogger() override fun onCreate(savedInstanceState: Bundle ? ) { ... fordefi!!.setLogger(logger) } } ``` ## Add error handling To receive error reports from the Fordefi SDK, you can create your own class implementing interface `IFordefiErrorHandler`, and call the function `setErrorHandler` with an instance of this class. ```kotlin import com.fordefi.fordefi.FordefiError import com.fordefi.fordefi.IFordefiErrorHandler class MyFordefiErrorHandler: IFordefiErrorHandler { override fun handleError(error: FordefiError) { Log.e("FordefiSDK", error.description()) } } class MainActivity: ComponentActivity() { private val errorHandler = MyFordefiErrorHandler() override fun onCreate(savedInstanceState: Bundle ? ) { ... fordefi!!.setErrorHandler(errorHandler) } }. ```