You can change PSPDFKit’s log level using LogLevelMask. It’s best to change the log level early on, for example in UIApplicationDelegate.application(_:willFinishLaunchingWithOptions:).

The default log level is [.info, .warning, .error, .critical]:

// Change log level to be more verbose.
PSPDFKit.SDK.shared.logLevel = [.info, .warning, .error, .critical, .verbose]
// Change log level to be more verbose.
PSPDFKitGlobal.sharedInstance.logLevel = PSPDFLogLevelMaskInfo|PSPDFLogLevelMaskWarning|PSPDFLogLevelMaskError|PSPDFLogLevelMaskCritical|PSPDFLogLevelMaskVerbose;

Available Log Levels:

If you want to learn more about the different log levels, please take a look at LogLevelMask.

Custom Log Handler

PSPDFKit also allows you to set a custom log handler to forward logging to a different system. By default, NSLog is used for logging. Here’s how you can set a different log handler:

PSPDFKit.SDK.shared.setLogHandler { level, tag, message, file, function, line in
    switch level {
    case .error:
        print("[PSPDFKit] Error in \(function): \(message())")
        print("[PSPDFKit] \(message())")
[PSPDFKitGlobal.sharedInstance setLogHandler:^(PSPDFLogLevelMask level, const char *tag, NSString *(^message)(void), const char *file, const char *function, NSUInteger line) {
    switch (level) {
        case PSPDFLogLevelMaskError:
            NSLog(@"[PSPDFKit] Error in %s: %@", function, message());

            NSLog(@"[PSPDFKit] %@", message());

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

case .critical:
    print("[PSPDFKit] \(function): \(message())")

    let attributes = [
        "function_name": "\(function)/\(line)",
        "message": message(),
        // Capture the stack trace.
        "stack_trace": Thread.callStackSymbols.joined(separator: "\n")
    Analytics.logCriticalEvent(with: attributes)
case PSPDFLogLevelMaskCritical:
    NSLog(@"[PSPDFKit] %s: %@", function, message());

    NSDictionary<NSString *, NSString *> *attributes = @{
      @"function_name": [NSString stringWithFormat:@"%s/%tu", function, line],
      @"message": message(),
      // Capture the stack trace.
      @"stack_trace": [NSThread.callStackSymbols componentsJoinedByString:@"\n"]
    [Analytics logCriticalEventWithAttributes:attributes];

See PSPDFKit.SDK.setLogHandler(handler:) for more information.