# React Native Implement logging and error handling for React Native. ## Add logging To add logging, perform the following steps: 1. Register for events callbacks. ```typescript const registerEventsCallback = async () => { const eventEmitter = Platform.OS === 'ios' ? new NativeEventEmitter(NativeModules.FordefiSdk) : new NativeEventEmitter(NativeModules.FordefiSdkModule); ``` 1. Add an events listener to the event type `LogEvent`: ```typescript eventEmitter.addListener('LogEvent', (event) => { console.log(`${event.logLevel}: ${event.logMessage}`); }); ``` 1. After the Fordefi SDK is initialized, call the [setLogger](https://documentation.fordefi.com/react-native/functions/setLogger.html) method with one of the desired LogLevels (`type LogLevel = 'verbose' | 'info' | 'warning' | 'error'`): ```typescript await setLogger("info"); ``` ## Add error handling To add error handling, perform the following steps: 1. Register events callback. ```typescript const registerEventsCallback = async () => { const eventEmitter = Platform.OS === 'ios' ? new NativeEventEmitter(NativeModules.FordefiSdk) : new NativeEventEmitter(NativeModules.FordefiSdkModule); ``` 1. Add events listener to event type `ErrorEvent`: ```typescript const eventEmitter = Platform.OS === 'ios' ? new NativeEventEmitter(NativeModules.FordefiSdk): new NativeEventEmitter(NativeModules.FordefiSdkModule); eventEmitter.addListener('ErrorEvent', event => { console.log(`Error ${event.errorCode}: ${event.errorMessage}`); }); ``` 1. After the Fordefi SDK is initialized, call the [setErrorHandler](https://documentation.fordefi.com/react-native/functions/setErrorHandler.html) method: ```typescript await setErrorHandler(); ```