---
title: Configuring logging on iOS
description: PingOne Advanced Identity Cloud PingAM iOS
component: orchsdks
page_id: orchsdks:journey:customization/logging/ios-custom-logging
canonical_url: https://developer.pingidentity.com/orchsdks/journey/customization/logging/ios-custom-logging.html
keywords: ["Journeys", "Android", "Logging", "Debug", "Console"]
section_ids:
  configuring_ios_logging: Configuring iOS logging
  defining_and_using_custom_loggers: Defining and using custom loggers
  ios_logger_module: Step 1. Installing modules
  add_dependencies_using_spm_swift_package_manager: Add dependencies using SPM (Swift Package Manager)
  add_dependencies_using_cocoapods: Add dependencies using CocoaPods
  step_2_defining_and_using_custom_loggers: Step 2. Defining and using custom loggers
---

# Configuring logging on iOS

[icon: circle-check, set=far]PingOne Advanced Identity Cloud [icon: circle-check, set=far]PingAM [icon: apple, set=fab]iOS

When you develop applications with the Orchestration SDK, you might need to understand its internal workings or troubleshoot unexpected behavior.

Use logging to gain crucial insights into your application's operations, identify issues, verify expected functionality, and better understand authentication flows.

This section covers how to configure and customize the logging output from the Orchestration SDK for iOS.

## Configuring iOS logging

To configure the logging output from the Orchestration SDK for iOS, specify the logger to use in the client module configuration:

Setting the logging level in the journey client configuration

```swift
import PingLogger

let journey = Journey.createJourney { config in
  config.logger = LogManager.standard
  config.serverUrl = "https://openam-forgerock-sdks.forgeblocks.com/am"
  config.realm = "alpha"
  config.cookie = "ch15fefc5407912"
}
```

The Orchestration SDK for iOS includes the following logger presets:

| Logger preset | Description                                                 |
| ------------- | ----------------------------------------------------------- |
| `standard`    | Outputs all log messages to the console.                    |
| `warning`     | Outputs only warning and error log messages to the console. |
| `none`        | Prevents all log messages.                                  |

|   |                                                                                                                                                                                                                                                                             |
| - | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|   | The `standard` logger tags messages in the console with the Orchestration SDK version. You can filter the console to only show the tagged messages:![Filtering console output by tag](../../../_images/logger/ios-console-tag.png)Figure 1. Filtering console output by tag |

## Defining and using custom loggers

In addition to the preset loggers you can create your own loggers. For example, you could output Orchestration SDK for Android messages to a file or a third-party service, or filter which messages to display.

### Step 1. Installing modules

To create custom loggers, you need to add the **Logger** module for iOS as a dependency to your project.

You can use Swift Package Manager (SPM) or Cocoapods to add the dependencies to your iOS project.

#### Add dependencies using SPM (Swift Package Manager)

You can install this by using SPM (Swift Package Manager) on the generated iOS project.

1. In Xcode,in the Project Navigator, right-click your project, and then click Add Package Dependencies…​.

2. In the **Search or Enter Package URL** field, enter the URL of the repo containing the DaVinci module for iOS, `https://github.com/ForgeRock/ping-ios-sdk.git`.

3. In **Add to Project**, select the name of your project, and then click **Add Package**.

   Xcode shows a dialog containing the libraries available in the Orchestration SDK for iOS.

4. Select the `PingLogger` library, and in the **Add to Target** column select the name of your project.

5. Repeat the previous step for any other Orchestration SDK libraries you want to add to your project.

6. Click **Add Package**.

   Xcode displays the chosen libraries and any prerequisites they might have in the **Package Dependencies** pane of the Project Navigator:

   ![Package dependencies in the Xcode package navigator pane.](../../../davinci/_images/Xcode-package-dependencies-dv-client.png)Figure 2. Package dependencies in the Xcode package navigator pane.

#### Add dependencies using CocoaPods

1. If you do not already have CocoaPods, install the [latest version](https://guides.cocoapods.org/using/getting-started.html).

2. If you do not already have a Podfile, in a terminal window, run the following command to create a new [Podfile](https://guides.cocoapods.org/syntax/podfile.html):

   ```
   pod init
   ```

3. Add the following lines to your Podfile:

   ```
   pod 'PingLogger'
   ```

4. Run the following command to install pods:

   ```
   pod install
   ```

### Step 2. Defining and using custom loggers

To create a custom logger, first define a class and override each of the logger methods with the new behavior.

For example, the following code creates a custom logger named `warningErrorOnly`, that only outputs warning and error messages, and ignores both info and debug messages:

Defining a custom logger class on iOS

```swift
import PingLogger

struct WarningErrorOnlyLogger: Logger {

  func i(_ message: String) {
  }

  func d(_ message: String) {
  }

  func w(_ message: String, error: Error?) {
    if let error = error {
      print("\(message): \(error)")
    } else {
      print(message)
    }
  }

  func e(_ message: String, error: Error?) {
    if let error = error {
      print("\(message): \(error)")
    } else {
      print(message)
    }
  }
}

extension LogManager {
  static var warningErrorOnly: Logger {
    return WarningErrorOnlyLogger()
  }
}
```

To use the custom logger in your app, specify the logger's name, just as with the preset loggers:

Using a custom logger with the Journey module on iOS

```swift
let journey = Journey.createJourney { config in
  config.logger = warningErrorOnly
  config.serverUrl = "https://openam-forgerock-sdks.forgeblocks.com/am"
  config.realm = "alpha"
  config.cookie = "ch15fefc5407912"
}
```
