You can use our APIs to send your mobile apps logs to New Relic. Your logs will be in one place where you can analyze them.
APIs to capture logs
APIs are available for iOS and Android.
Important
Note that there may be some mobile logging delays:
- It will take up to 15 minutes for logs to appear in New Relics Logs tab.
- It will take up to 15 minutes for changes to mobile logs toggle, sampling rate, and log level to be reflected within your mobile application.
Keep in mind that when you use the logging APIs, you should only use the debug log level if you want to see agent debugging logs.
iOS agent
To use the logging APIs add the following:
NewRelic.logError("Encountered error=error=\(error.localizedDescription).")
NewRelic.logWarning("Warning text.")
NewRelic.logInfo("Info text.")
NewRelic.logVerbose("NewRelic.start was called.")
NewRelic.logDebug("Debug text.")
do { try errorMethod()} catch { NewRelic.logErrorObject(error)}
NewRelic.logAll([ "logLevel": "WARN", "message": "This is a test message for the New Relic logging system."])
NewRelic.logAttributes([ "logLevel": "WARN", "message": "This is a test message for the New Relic logging system.", "additionalAttribute1": "attribute1", "additionalAttribute2": "attribute2"])
Android agent
To use the logging APIs add the following:
NewRelic.logInfo(String message)
NewRelic.logWarning(String message)
NewRelic.logDebug(String message)
NewRelic.logVerbose(String message)
NewRelic.logError(String message)
NewRelic.log(LogLevel logLevel, String message)
NewRelic.logThrowable(LogLevel logLevel, String message, Throwable throwable)
NewRelic.logAttributes(Map<String, Object> attributes)
NewRelic.logAll(Throwable throwable, Map<String, Object> attributes)
Enable mobile logs
By default, our mobile agent doesn't collect logs. To enable mobile logs:
- Go to one.newrelic.com > All capabilities.
- Click Mobile.
- Click on your mobile app.
- In the left pane under Settings, click Application.
- Toggle Mobile Logs on.
- Click Save.
Configure your logs
To configure your mobile logs sampling rate or log level:
- In New Relic, navigate to your mobile app.
- In the left pane under Settings, click Application.
- To change the sample rate, select a new value in the field under Sample rate of total sessions.
- To change the log level, select your preferred log level in the dropdown under Logs verbosity. The debug log level should only be used if you want to see agent debugging logs.
View logs in New Relic
To view your logs, continue in the New Relic UI:
- Navigate to your mobile app.
- In the left pane under Triage, click Logs.