# Customizing the log level on iOS

You can change Nutrient’s log level using the [`logLevel`](https://www.nutrient.io/api/ios/documentation/pspdfkit/sdk/loglevel) property. It’s best to change the log level early on — for example, in `application(_:willFinishLaunchingWithOptions:)`:

### SWIFT

```swift

// Increase the log level to include debug messages.
PSPDFKit.SDK.shared.logLevel =.debug

```

### OBJECTIVE-C

```objc

// Increase the verbosity to include debug messages.
PSPDFKitGlobal.sharedInstance.logLevel = PSPDFLogLevelDebug;

```

The available log levels, in order of decreasing severity, are:

- [`.critical`](https://www.nutrient.io/api/ios/documentation/pspdfkit/loglevel/critical)

- [`.error`](https://www.nutrient.io/api/ios/documentation/pspdfkit/loglevel/error)

- [`.warning`](https://www.nutrient.io/api/ios/documentation/pspdfkit/loglevel/warning)

- [`.info`](https://www.nutrient.io/api/ios/documentation/pspdfkit/loglevel/info) (default)

- [`.debug`](https://www.nutrient.io/api/ios/documentation/pspdfkit/loglevel/debug)

- [`.verbose`](https://www.nutrient.io/api/ios/documentation/pspdfkit/loglevel/verbose)

Setting a log level implies enabling all log levels with higher severity. For example, setting `.warning` also enables the logging of messages with `.error` or `.critical` severity.

Setting the log level to `.debug` or `.verbose` will have a significant performance impact on your app. We strongly recommend against using either of them in release builds.

To learn more about the different log levels, take a look at [`LogLevel`](https://www.nutrient.io/api/ios/documentation/pspdfkit/loglevel).

## Custom log handler

By default, Nutrient uses `OSLog` to send logs to the operating system. You can override this behavior and use your own logging service instead of or in addition to `OSLog`:

### SWIFT

```swift

PSPDFKit.SDK.shared.setLogHandler { level, tag, message, file, function, line in
    // Respect the configured log level.
    guard PSPDFKit.SDK.shared.logLevel >= level else {
        return
    }
    switch level {
        case.error:
            print("[PSPDFKit] Error in \(function): \(message())")
        default:
            print("[PSPDFKit] \(message())")
    }
}

```

### OBJECTIVE-C

```objc

[PSPDFKitGlobal.sharedInstance setLogHandler:^(PSPDFLogLevel level, const char *tag, NSString *(^message)(void), const char *file, const char *function, NSUInteger line) {
    // Respect the configured log level.
    if (PSPDFKitGlobal.sharedInstance.logLevel < level) {
        return
    }
    switch (level) {
        case PSPDFLogLevelError:
            NSLog(@"[PSPDFKit] Error in %s: %@", function, message());
            break;
        default:
            NSLog(@"[PSPDFKit] %@", message());
            break;
    }
}];

```

In this way, you can also report critical logs to your analytics or crash reporting service to gain more insight into which logs your users are hitting. You may also capture the current stack trace and attach it to the service you’re using:

### SWIFT

```swift

case.critical:
    print("[PSPDFKit] Critical error in \(function): \(message())")
    MyAnalyticsService.logCriticalEvent(attributes: [
        "source": "\(file)/\(function)/\(line)",
        "message": message(),
        // Capture the stack trace.
        "stack_trace": Thread.callStackSymbols.joined(separator: "\n")
    ])

```

### OBJECTIVE-C

```objc

case PSPDFLogLevelCritical:
    NSLog(@"[PSPDFKit] Critical error in %s: %@", function, message());
    [MyAnalyticsService logCriticalEventWithAttributes:@{
        @"source": [NSString stringWithFormat:@"%s/%s/%tu", file, function, line],
        @"message": message(),
        // Capture the stack trace.
        @"stack_trace": [NSThread.callStackSymbols componentsJoinedByString:@"\n"]
    }];

```

To learn more about customizing the log handler and using custom analytics services, check out the API reference for [`setLogHandler(_:)`](https://www.nutrient.io/api/ios/documentation/pspdfkit/sdk/setloghandler(_:)) and our [Adding Logging to Crash Reports](https://www.nutrient.io/blog/logs-for-your-crash-reports/) blog post.
---

## Related pages

- [Advanced CocoaPods integration](/guides/ios/miscellaneous/advanced-cocoapods-integration.md)
- [App Transport Security](/guides/ios/pspdfkit-instant/app-transport-security.md)
- [Advanced Carthage integration](/guides/ios/miscellaneous/advanced-carthage-integration.md)
- [Bitcode](/guides/ios/faq/bitcode.md)
- [Carthage integration](/guides/ios/best-practices/carthage-integration.md)
- [Framework Size](/guides/ios/faq/framework-size.md)
- [Airdrop](/guides/ios/features/airdrop.md)
- [Customizing The Page Number](/guides/ios/customizing-pdf-pages/customizing-the-page-number.md)
- [Nightly Builds](/guides/ios/best-practices/nightly-builds.md)
- [About Memory Usage](/guides/ios/memory-and-storage/about-memory-usage.md)
- [iOS PDF SDK security](/guides/ios/faq/sdk-security.md)
- [Powered By Nutrient](/guides/ios/miscellaneous/powered-by-nutrient.md)
- [Optimize PDF documents for mobile rendering on iOS](/guides/ios/miscellaneous/optimize-pdf-documents-for-mobile-rendering.md)
- [Third Party Compatibility](/guides/ios/miscellaneous/third-party-compatibility.md)
- [Reduce App Size](/guides/ios/best-practices/reduce-app-size.md)
- [Modifying permissions in your iOS app](/guides/ios/getting-started/permissions.md)
- [Transferring File Edits To A Server](/guides/ios/best-practices/transferring-file-edits-to-a-server.md)
- [Saving Data Externally](/guides/ios/memory-and-storage/saving-data-externally.md)
- [Using Document Efficiently](/guides/ios/getting-started/using-document-efficiently.md)
- [Using Automatic Saving Safely](/guides/ios/best-practices/using-automatic-saving-safely.md)
- [Manage your iOS status bar with view controllers](/guides/ios/faq/view-controller-based-status-bar-appearance.md)
- [Strategies For Multiple Bundle Ids](/guides/ios/faq/strategies-for-multiple-bundle-ids.md)
- [Youtube Links](/guides/ios/miscellaneous/youtube-links.md)
- [Version Numbering](/guides/ios/best-practices/version-numbering.md)

