How to use datadog log in native code?
Question
I want to use datadog log in Objective C and kotlin as for now, the documentation only write example of Javascript Code only
import { DdLogs } from '@datadog/mobile-react-native'; DdLogs.debug('A debug message.', { customAttribute: 'something' }) DdLogs.info('Some relevant information ?', { customCount: 42 }) DdLogs.warn('An important warning…', {}) DdLogs.error('An error was met!', {})
Hi there! 👋
From what I understand, you're looking to add logging to the native Android and iOS layers of a React Native app. If that's the case, you can follow our platform-specific guides:
Android (Kotlin): https://docs.datadoghq.com/logs/log_collection/android/?tab=kotlin#setup
iOS (Objective-C): https://docs.datadoghq.com/logs/log_collection/ios/?tab=objectivec
As long as the SDK is already initialized on the React Native side, the core instance is shared across the React Native and native (Android/iOS) layers. This means you can use the SDK in the native code just like you would in a purely native app, no extra steps needed on the RN side.
Hope this helps! Let me know if you have any questions.
@marco-saia-datadog is it possible to initialise react native datadog SDK on the native side for capturing metrics on the native layer ?
@marco-saia-datadog is it possible to initialise react native datadog SDK on the native side for capturing metrics on the native layer ?
Hey, sorry for the late reply.
Yes, as @marco-saia-datadog mentioned above, you can initialize the SDK either from React Native or from the native side and you'll be able to call the native SDK in both cases and capture metrics and logs in the same way.