---
title: Mobile logs
source: https://docs.newrelic.com/docs/mobile-monitoring/mobile-monitoring-ui/mobile-logs
---

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.

## Enable mobile logs [#enable-mobile-logs]

For newly created mobile entities, mobile logging is enabled by default with a 100% sample rate and a log level of `WARN`.

For existing entities where logging was previously disabled , or to verify your settings:

1.  Go to **[one.newrelic.com > All capabilities](https://one.newrelic.com/all-capabilities)**.
2.  Click **Mobile**.
3.  Click on your mobile app.
4.  In the left pane under **Settings**, click **Application Settings**.
5.  Toggle **Mobile Logs** on.
6.  Click **Save**.

-   **iOS Agent Requirement:** Automatic collection is **off by default**. To enable it:
    1.  You must enable the `NRFeatureFlag_AutoCollectLogs` feature flag in your app's initialization code.
    2.  The **Mobile Logs** toggle is turned **On** in the New Relic UI.

## Configure your logs [#configure-mobile-logs]

To configure the sampling rate or log level:

1.  In New Relic, navigate to your mobile app.
2.  In the left pane under **Settings**, click **Application Settings**.
3.  To change the sample rate, select a new value in the field under **Sample rate of total sessions**.
4.  To change the log level, select your preferred log level in the dropdown under **Logs verbosity**.

You can adjust the log level to control the volume of data ingested. Supported levels include

-   `ERROR`
-   `WARN` (Default for new apps)
-   `INFO`
-   `VERBOSE`
-   `DEBUG`

> #### 💡 TIP
>
> Only increase the log level to `VERBOSE` or `DEBUG` for temporary troubleshooting, as these levels significantly increase data ingest. We recommend using `WARN` or `ERROR` for release builds.

> #### ⚠️ IMPORTANT
>
> **Server-side Configuration:** Mobile log settings are controlled server-side. This means you **do not need to deploy a new version** of your app for changes to the toggle, sample rate, or log level to take effect. The agent will pick up the new configuration on the next app launch or configuration fetch.

## How logs are collected [#collection-methods]

-   **Manual API collection (Recommended):** Use our API to send specific **log messages, attributes, and exceptions.**
-   **Automatic collection:** The iOS agent can automatically capture logs sent to standard output (`stdout`) and standard error (`stderr`). You must enable the `NRFeatureFlag_AutoCollectLogs` feature flag in your app's initialization code for automatic log collection.

## View logs in New Relic [#view-logs-in-new-relic]

To view your logs in the UI:

1.  Navigate to your mobile app.
2.  In the left pane under **Triage**, click **Logs**.

Note that there may be some mobile logging delays:

-   It will take up to 15 minutes for logs to appear in the **Logs** page.
-   It will take up to 15 minutes for changes to the logs toggle, sampling rate, and log level to be reflected within your mobile application.

## Use APIs to capture logs [#logs-apis]

The API below provides a comprehensive set of logging methods to capture various types of information and events in your application. These methods allow you to log messages with different severity levels (info, warning, debug, verbose, error), custom log levels, and additional context such as throwables (exceptions) and attributes.

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.

### Android

#### Syntax [#syntax]

##### Java [#java]

```java
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)
```

##### Kotlin [#kotlin]

```kotlin
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)
```

#### Example [#example]

##### Java [#java]

```java
// Log info
NewRelic.logInfo("This is an info message");

// Log warning
NewRelic.logWarning("This is a warning message");

// Log debug
NewRelic.logDebug("This is a debug message");

// Log verbose
NewRelic.logVerbose("This is a verbose message");

// Log error
NewRelic.logError("This is an error message");

// Log with specific log level
NewRelic.log(LogLevel.INFO, "This is a log message with INFO level");

// Log throwable with specific log level
try {
    throw new Exception("This is a test exception");
} catch (Exception e) {
    NewRelic.logThrowable(LogLevel.ERROR, "Exception occurred", e);
}

// Log attributes
Map<String, Object> attributes = new HashMap<>();
attributes.put("key1", "value1");
attributes.put("key2", 123);
NewRelic.logAttributes(attributes);

// Log all with throwable and attributes
try {
    throw new Exception("This is another test exception");
} catch (Exception e) {
    NewRelic.logAll(e, attributes);
}
```

##### Kotlin [#kotlin]

```kotlin
// Log info
NewRelic.logInfo("This is an info message")

// Log warning
NewRelic.logWarning("This is a warning message")

// Log debug
NewRelic.logDebug("This is a debug message")

// Log verbose
NewRelic.logVerbose("This is a verbose message")

// Log error
NewRelic.logError("This is an error message")

// Log with specific log level
NewRelic.log(LogLevel.INFO, "This is a log message with INFO level")

// Log throwable with specific log level
try {
    throw Exception("This is a test exception")
} catch (e: Exception) {
    NewRelic.logThrowable(LogLevel.ERROR, "Exception occurred", e)
}

// Log attributes
val attributes = mapOf("key1" to "value1", "key2" to 123)
NewRelic.logAttributes(attributes)
```

### iOS

#### Syntax [#syntax]

##### Objective-c

```objectivec
(void) logInfo:(NSString* __nonnull) message;
(void) logError:(NSString* __nonnull) message;
(void) logVerbose:(NSString* __nonnull) message;
(void) logWarning:(NSString* __nonnull) message;
(void) logAudit:(NSString* __nonnull) message;
(void) logDebug:(NSString* __nonnull) message;
(void) log:(NSString* __nonnull) message level:(NRLogLevels)level;
(void) logAll:(NSDictionary* __nonnull) dict;
(void) logAttributes:(NSDictionary* __nonnull) dict;
(void) logErrorObject:(NSError* __nonnull) error;
```

##### Swift [#swift]

```swift
func logInfo(_ message: String)
func logError(_ message: String)
func logVerbose(_ message: String)
func logWarning(_ message: String)
func logAudit(_ message: String)
func logDebug(_ message: String)
func log(_ message: String, level: NRLogLevels)
func logAll(_ dict: [String: Any])
func logAttributes(_ dict: [String: Any])
func logErrorObject(_ error: NSError)
```

#### Example [#example]

##### Objective-c [#objective-c]

```objectivec
[NewRelic logInfo:@"This is an info message"];

[NewRelic logError:@"This is an error message"];

[NewRelic logVerbose:@"This is a verbose message"];

[NewRelic logWarning:@"This is a warning message"];

[NewRelic logAudit:@"This is an audit message"];

[NewRelic logDebug:@"This is a debug message"];

[NewRelic log:@"This is a custom log level message" level:NRLogLevelsCustom];

NSDictionary *logDict = @{@"key1": @"value1", @"key2": @"value2"};
[NewRelic logAll:logDict];

NSDictionary *attributesDict = @{@"attribute1": @"value1", @"attribute2": @"value2"};
[NewRelic logAttributes:attributesDict];

NSError *error = [NSError errorWithDomain:@"com.example" code:100 userInfo:@{NSLocalizedDescriptionKey: @"This is an error description"}];
[NewRelic logErrorObject:error];
```

##### Swift [#swift]

```swift
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"
])
```

### Capacitor

#### Syntax [#syntax]

```js
NewRelicCapacitorPlugin.logInfo(options: { message: string}) => void

NewRelicCapacitorPlugin.logVerbose(options: { message: string}) => void

NewRelicCapacitorPlugin.logError(options: { message: string}) => void

NewRelicCapacitorPlugin.logWarn(options: { message: string}) => void

NewRelicCapacitorPlugin.logDebug(options: { message: string}) => void

NewRelicCapacitorPlugin.logAll(options: { error: string; attributes: object; }): void

NewRelicCapacitorPlugin.logAttributes(options: { attributes: object; }): void
```

#### Example [#example]

```ts
NewRelicCapacitorPlugin.logInfo({message: "User profile loaded successfully"});

NewRelicCapacitorPlugin.logVerbose({message:"Verbose logging example"});

NewRelicCapacitorPlugin.logError({message:"Error loading user profile"});

NewRelicCapacitorPlugin.logWarn({message: "Low disk space warning"});

NewRelicCapacitorPlugin.logDebug({message:"Debugging session started"});

NewRelicCapacitorPlugin.logAll({
  error: "UnexpectedError",
  attributes: { "errorCode": "500", "errorMessage": "Internal Server Error" ,level:"WARN"}
});

NewRelicCapacitorPlugin.logAttributes({attributes:{
  "userID": 12345,
  "sessionID": "abcde12345",
  "isLoggedIn": true,
  "message":"this is test",
  "level":"INFO"
}});
```

### Cordova

#### Syntax [#syntax]

```js
NewRelic.logInfo(message: string): void;

NewRelic.logDebug(message: string): void;

NewRelic.logVerbose(message: string): void;

NewRelic.logWarn(message: string): void;

NewRelic.logError(message: string): void;

NewRelic.log(level: string, message: string): void;

NewRelic.logAttributes(attributes: {[key: string]: boolean | number | string}): void;
```

#### Example [#example]

```js
NewRelic.logInfo("User logged in successfully");

NewRelic.logDebug("Debug message");

NewRelic.logVerbose("Verbose message detailing step-by-step execution");

NewRelic.logWarn("Warning message indicating a potential issue");

NewRelic.logError("Error message indicating a failure");

NewRelic.log("INFO", "User logged in successfully");

NewRelic.logAttributes({
  "userID": 12345,
  "sessionID": "abcde12345",
  "isLoggedIn": true,
  "message":"this is test",
  "level":"INFO"
});
```

### .NET MAUI

#### Syntax [#syntax]

```csharp
CrossNewRelic.Current.LogInfo(String message) : void

CrossNewRelic.Current.LogError(String message) : void

CrossNewRelic.Current.LogVerbose(String message) : void

CrossNewRelic.Current.LogWarning(String message) : void

CrossNewRelic.Current.LogDebug(String message) : void

CrossNewRelic.Current.Log(LogLevel level, String message) : void

CrossNewRelic.Current.LogAttributes(Dictionary<string, object> attributes) : void
```

#### Example [#example]

```csharp
CrossNewRelic.Current.LogInfo("This is an informational message");

CrossNewRelic.Current.LogError("This is an error message");

CrossNewRelic.Current.LogVerbose("This is a verbose message");

CrossNewRelic.Current.LogWarning("This is a warning message");

CrossNewRelic.Current.LogDebug("This is a debug message");

CrossNewRelic.Current.Log(LogLevel.Info, "This is an informational message");

CrossNewRelic.Current.LogAttributes(new Dictionary<string, object>()
    {
        { "level","info"},
        { "BreadNumValue", 12.3 },
        { "BreadStrValue", "MAUIBread" },
        { "BreadBoolValue", true },
        { "message", "This is a message with attributes" }
    }
);
```

### Flutter

#### Syntax [#syntax]

```dart
NewrelicMobile.instance.logInfo(String message) : void

NewrelicMobile.instance.logError(String message) : void

NewrelicMobile.instance.logVerbose(String message) : void

NewrelicMobile.instance.logWarning(String message) : void

NewrelicMobile.instance.logDebug(String message) : void

NewrelicMobile.instance.log(LogLevel level, String message) : void

NewrelicMobile.instance.logAll(Exception exception,Map<String, dynamic>? attributes) : void

NewrelicMobile.instance.logAttributes(Dictionary<string, object> attributes) : void
```

#### Example [#example]

```dart
NewrelicMobile.instance.logInfo("This is an informational message");

NewrelicMobile.instance.logError("This is an error message");

NewrelicMobile.instance.logVerbose("This is a verbose message");

NewrelicMobile.instance.logWarning("This is a warning message");

NewrelicMobile.instance.logDebug("This is a debug message");

NewrelicMobile.instance.log(LogLevel.Info, "This is an informational message");

NewrelicMobile.instance.logAll(Exception("This is an exception"), {
  "BreadNumValue": 12.3,
  "BreadStrValue": "FlutterBread",
  "BreadBoolValue": true,
  "message": "This is a message with attributes",
   "level":"info"
});

NewrelicMobile.instance.logAttributes({
  "BreadNumValue": 12.3,
  "BreadStrValue": "FlutterBread",
  "BreadBoolValue": true,
  "message": "This is a message with attributes",
  "level":"info"
});
```

### React Native

#### Syntax [#syntax]

```js
NewRelic.logInfo(String message) : void

NewRelic.logError(String message) : void

NewRelic.logVerbose(String message) : void

NewRelic.logWarning(String message) : void

NewRelic.logDebug(String message) : void

NewRelic.log(LogLevel level, String message) : void

NewRelic.logAll(Error error,attributes?: {[key: string]: any}) : void

NewRelic.logAttributes(attributes?: {[key: string]: any}) : void
```

#### Example [#example]

```js
NewRelic.logInfo();

NewRelic.logError("This is an error message");

NewRelic.logVerbose("This is a verbose message");

NewRelic.logWarning("This is a warning message");

NewRelic.logDebug("This is a debug message");

NewRelic.log(LogLevel.INFO, "This is an informational message");

Newrelic.logAll(new Error("This is an exception"), {
  BreadNumValue: 12.3,
  BreadStrValue: "FlutterBread",
  BreadBoolValue: true,
  message: "This is a message with attributes",
});

Newrelic.logAttributes({
  BreadNumValue: 12.3,
  BreadStrValue: "FlutterBread",
  BreadBoolValue: true,
  message: "This is a message with attributes",
  level: newRelic.LogLevel.INFO,
});
```

### Xamarin

#### Syntax [#syntax]

```csharp
CrossNewRelicClient.Current.LogInfo(String message) : void

CrossNewRelicClient.Current.LogError(String message) : void

CrossNewRelicClient.Current.LogVerbose(String message) : void

CrossNewRelicClient.Current.LogWarning(String message) : void

CrossNewRelicClient.Current.LogDebug(String message) : void

CrossNewRelicClient.Current.Log(LogLevel level, String message) : void

CrossNewRelicClient.Current.LogAttributes(Dictionary<string, object> attributes) : void
```

#### Example [#example]

```csharp
CrossNewRelicClient.Current.LogInfo("This is an informational message");

CrossNewRelicClient.Current.LogError("This is an error message");

CrossNewRelicClient.Current.LogVerbose("This is a verbose message");

CrossNewRelicClient.Current.LogWarning("This is a warning message");

CrossNewRelicClient.Current.LogDebug("This is a debug message");

CrossNewRelicClient.Current.Log(LogLevel.Info, "This is an informational message");

CrossNewRelicClient.Current.LogAttributes(new Dictionary<string, object>()
    {
        {"level", "info"},
        { "BreadNumValue", 12.3 },
        { "BreadStrValue", "XamBread" },
        { "BreadBoolValue", true },
        { "message", "This is a message with attributes" }
    }
);
```

### Unity

#### Syntax [#syntax]

```csharp
NewRelicAgent.LogInfo(String message) : void

NewRelicAgent.LogError(String message) : void

NewRelicAgent.LogVerbose(String message) : void

NewRelicAgent.LogWarning(String message) : void

NewRelicAgent.LogDebug(String message) : void

NewRelicAgent.Log(LogLevel level, String message) : void

NewRelicAgent.LogAttributes(Dictionary<string, object> attributes) : void
```

#### Example [#example]

```csharp
NewRelicAgent.LogInfo("This is an informational message");

NewRelicAgent.LogError("This is an error message");

NewRelicAgent.LogVerbose("This is a verbose message");

NewRelicAgent.LogWarning("This is a warning message");

NewRelicAgent.LogDebug("This is a debug message");

NewRelicAgent.Log(LogLevel.Info, "This is an informational message");

NewRelicAgent.LogAttributes(new Dictionary<string, object>()
        {
            {"level", "info"},
            {"BreadNumValue", 12.3 },
            {"BreadStrValue", "UnityBread" },
            {"BreadBoolValue", true },
            {"message", "This is a message with attributes" }
        }
    );
```

### Unreal

#### Syntax [#syntax]

```c
UNewRelicBPLibrary::logInfo(FString message) : void

UNewRelicBPLibrary::logError(FString message) : void

UNewRelicBPLibrary::logVerbose(FString message) : void

UNewRelicBPLibrary::logWarning(FString message) : void

UNewRelicBPLibrary::logDebug(FString message) : void

UNewRelicBPLibrary::log(AgentLogLevel level, FString message) : void

UNewRelicBPLibrary::logAttributes(TMap <FString, FString> attributes) : void
```

#### Example [#example]

```c
#include "NewRelicBPLibrary.h"

UNewRelicBPLibrary::logInfo("This is an informational message");

UNewRelicBPLibrary::logError("This is an error message");

UNewRelicBPLibrary::logVerbose("This is a verbose message");

UNewRelicBPLibrary::logDebug("This is a debug message");

UNewRelicBPLibrary::logWarning("This is a warning message");

UNewRelicBPLibrary::log(AgentLogLevel::Debug, "This is a debug message");

TMap<FString, FString> attributes;
attributes.Add("place", TEXT("Robots"));
attributes.Add("user", TEXT("user1"));
attributes.Add("level", TEXT("DEBUG"));
attributes.Add("message", TEXT("This is a debug message"));

UNewRelicBPLibrary::logAttributes(attributes);
```
