---
title: Configure logging
description: Applies to:
component: sdks
version: latest
page_id: sdks:sdks:customize/how-to-custom-loggers
canonical_url: https://docs.pingidentity.com/sdks/latest/sdks/customize/how-to-custom-loggers.html
llms_txt: https://docs.pingidentity.com/sdks/llms.txt
docs_for_agents: https://developer.pingidentity.com/build-with-ai/docs-for-agents.md
revdate: Wed, 17 May 2023 14:10:20 +0100
keywords: ["PingOne Advanced Identity Cloud", "PingAM", "Journeys", "Setup &amp; Configuration", "Source Code", "Customization", "SDK"]
section_ids:
  android: Android
  default-logger-android: Configure default Android logging
  customize-logger-android: Customize Android logging
  ios: iOS
  default-logger-ios: Configure the default iOS logging
  customize-logger-ios: Customize iOS logging
  javascript: JavaScript
  default-logger-javascript: Configure the default JavaScript logging
  customize-logger-javascript: Customize JavaScript logging
---

# Configure logging

***Applies to***:

* [icon: check-square-o, set=fa]Ping (ForgeRock) SDK for Android

* [icon: check-square-o, set=fa]Ping (ForgeRock) SDK for iOS

* [icon: check-square-o, set=fa]Ping (ForgeRock) SDK for JavaScript

This page covers how to use the default logging in the Ping (ForgeRock) SDKs, and how to customize logging.

[icon: android, set=fab, size=3x]

#### [Ping (ForgeRock) SDK for Android](#android)

Configure Ping (ForgeRock) SDK for Android logging

[icon: apple, set=fab, size=3x]

#### [Ping (ForgeRock) SDK for iOS](#ios)

Configure Ping (ForgeRock) SDK for iOS logging

[icon: js, set=fab, size=3x]

#### [Ping (ForgeRock) SDK for JavaScript](#javascript)

Configure Ping (ForgeRock) SDK for JavaScript logging

## Android

### Configure default Android logging

The Ping (ForgeRock) SDK for Android does all of its logging through a custom interface called `FRLogger`. The default implementation of this interface logs the messages through the native Android [Log](https://developer.android.com/reference/android/util/Log) class. This displays messages from the SDK in real-time in the Logcat window in Android Studio.

The log severity levels defined in the Ping (ForgeRock) SDK for Android are as follows:

| Log level | Description                                                                                                                                                                                                   |
| --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `DEBUG`   | Show debug log messages intended only for development, as well as the message levels lower in this list; `INFO`, `WARN`, and `ERROR`.In addition, all network activities of the SDK are included in the logs. |
| `INFO`    | Show expected log messages for regular usage, as well as the message levels lower in this list, `WARN`, and `ERROR`.                                                                                          |
| `WARN`    | Show possible issues that are not yet errors, as well as the messages of `ERROR` log level.                                                                                                                   |
| `ERROR`   | Show issues that caused errors.                                                                                                                                                                               |
| `NONE`    | No log messages are shown.                                                                                                                                                                                    |

|   |                                                                                                                                                                                                                                                                                                                                                                           |
| - | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|   | The log levels are cumulative.If you select a lower severity level, all messages logged at higher severity levels are also included. For example, if you select the `DEBUG` level, the log includes all events logged at the `DEBUG`, `INFO`, `WARN`, and `ERROR` levels.By default, the log level of the Ping (ForgeRock) SDK for Android is set to `Logger.Level.WARN`. |

### Customize Android logging

The Ping (ForgeRock) SDK for Android allows developers to customize the default logger behavior:

1. Create a class that implements the `FRLogger` interface:

   ```java
   import androidx.annotation.Nullable;
   import org.forgerock.android.auth.FRLogger;

   public class MyCustomLogger implements FRLogger {
       @Override
       public void error(@Nullable String tag, @Nullable Throwable t, @Nullable String message, @Nullable Object... values) {
           /// Custom error message handling...
       }

       @Override
       public void error(@Nullable String tag, @Nullable String message, @Nullable Object... values) {
           /// Custom error message handling...
       }

       @Override
       public void warn(@Nullable String tag, @Nullable String message, @Nullable Object... values) {
           /// Custom warning message handling...
       }

       @Override
       public void warn(@Nullable String tag, @Nullable Throwable t, @Nullable String message, @Nullable Object... values) {
           /// Custom warning message handling...
       }

       @Override
       public void debug(@Nullable String tag, @Nullable String message, @Nullable Object... values) {
           /// Custom debug message handling...
       }

       @Override
       public void info(@Nullable String tag, @Nullable String message, @Nullable Object... values) {
           /// Custom info message handling...
       }

       @Override
       public void network(@Nullable String tag, @Nullable String message, @Nullable Object... values) {
           /// Custom network details handling...
       }

       @Override
       public boolean isNetworkEnabled() {
           return true; // include network call details in the logs
       }
   }
   ```

2. In your application, set the custom logger and desired log level:

   ```java
   Logger.setCustomLogger(new MyCustomLogger()); // The default logger will no longer be active
   Logger.set(Logger.Level.DEBUG);
   ```

3. You can now use the `Logger` interface in your app.

   For example:

   ```java
   String TAG = MainActivity.class.getSimpleName();
   Logger.debug (TAG, "Happy logging!");
   ```

## iOS

### Configure the default iOS logging

The Ping (ForgeRock) SDK for iOS does all of its logging through a custom protocol called `FRLogger`. The default implementation of the `FRLogger` protocol logs the messages through the native iOS [FRConsoleLogger](https://github.com/ForgeRock/forgerock-ios-sdk/blob/develop/FRCore/FRCore/Log/FRConsoleLogger.swift) class. This displays messages from the SDK in real-time in the console window in Xcode.

Each log message has an associated log level that describes the type and the severity of the message. Log levels are helpful tool for tracking and analyzing events that take place in your app.

The log severity levels defined in the Ping (ForgeRock) SDK for iOS are as follows:

| Log level | Description                                                                                |
| --------- | ------------------------------------------------------------------------------------------ |
| `none`    | Prevent logging                                                                            |
| `verbose` | Logs that are not important or can be ignored                                              |
| `info`    | Logs that maybe helpful or meaningful for debugging, or understanding the flow             |
| `network` | Logs for network traffic, including request and response                                   |
| `warning` | Logs that are a minor issue or an error that can be ignored                                |
| `error`   | Logs that are a severe issue or a major error that impacts the SDK's functionality or flow |
| `all`     | Logs at all levels                                                                         |

|   |                                                                                                                                                                                                                                                                                                                                                                                                  |
| - | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|   | The log levels are **not** cumulative. That is, you should explicitly specify all the log levels you want to record.For example, if you select the `debug` level, the output only includes events logged at `debug` level.To include other levels, you must specify an array of the required log levels.By default, the log level of the Ping (ForgeRock) SDK for iOS is set to `LogLevel.none`. |

### Customize iOS logging

The Ping (ForgeRock) SDK for iOS lets developers customize the default logger behavior:

1. Create a class that conforms to the `FRLogger` protocol:

   ```swift
   class MyCustomLogger: FRLogger {
       func logVerbose(timePrefix: String, logPrefix: String, message: String) {
           /// Custom verbose message handling...
       }

       func logInfo(timePrefix: String, logPrefix: String, message: String) {
           /// Custom info message handling...
       }

       func logNetwork(timePrefix: String, logPrefix: String, message: String) {
           /// Custom network message handling...
       }

       func logWarning(timePrefix: String, logPrefix: String, message: String) {
           /// Custom warning message handling...
       }

       func logError(timePrefix: String, logPrefix: String, message: String) {
           /// Custom error message handling...
       }
   }
   ```

2. In your application, set the custom logger and desired log level:

   ```swift
   FRLog.setCustomLogger(MyCustomLogger()) // The default logger will no longer be active
   FRLog.setLogLevel([.all])
   ```

3. You can now use the `FRLog` class in your app.

   For example:

   ```swift
   FRLog.v("Happy logging!")
   ```

## JavaScript

### Configure the default JavaScript logging

The Ping (ForgeRock) SDK for JavaScript performs logging through the native `console` class. This displays messages from the SDK in real-time in the console window provided in many browsers.

The default `logLevel` is `none`, which prevents the Ping (ForgeRock) SDK for JavaScript from logging any messages to the console.

To enable the output of log messages from the Ping (ForgeRock) SDK for JavaScript, specify a `logLevel` value other than `none`.

For example, use the following code to specify the `debug` level:

Setting the log level in the Ping (ForgeRock) SDK for JavaScript configuration

```javascript
Config.setAsync({
  serverConfig: {
    wellknown: '{edit_cloud_url}/oauth2/realms/root/realms/alpha/.well-known/openid-configuration',
    timeout: 5000,
  },
  logLevel: 'debug',
});
```

The log severity levels defined in the Ping (ForgeRock) SDK for JavaScript are as follows:

| Log level | Description                                                                                                                                                                                                   |
| --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `debug`   | Show debug log messages intended only for development, as well as the message levels lower in this list; `info`, `warn`, and `error`.In addition, all network activities of the SDK are included in the logs. |
| `info`    | Show expected log messages for regular usage, as well as the message levels lower in this list, `warn`, and `error`.                                                                                          |
| `warn`    | Show possible issues that are not yet errors, as well as the messages of `error` log level.                                                                                                                   |
| `error`   | Show issues that caused errors.                                                                                                                                                                               |
| `none`    | No log messages are shown. This is the default setting.                                                                                                                                                       |

|   |                                                                                                                                                                                                                                                                                     |
| - | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|   | The log levels are cumulative. If you select a lower severity level, all messages logged at higher severity levels are also included.For example, if you select the `debug` level, the output includes all events logged by the SDK at `debug`, `info`, `warn`, and `error` levels. |

For more information on configuring the Ping (ForgeRock) SDK for JavaScript, refer to [Ping (ForgeRock) SDK for JavaScript Properties](../configure-the-sdks.html#javascript-properties)

### Customize JavaScript logging

The Ping (ForgeRock) SDK for JavaScript allows developers to customize the default logger behavior. For example, you might want to redirect the logs to an external service.

1. Create a function that implements the `LoggerFunctions` interface.

   For example, the following code adds a prefix to each log message from the SDK and logs it to the console:

   ```javascript
   const customLogger = {
     warn: (msg) => console.warn(`[FR SDK] ${msg}`),
     error: (msg) => console.error(`[FR SDK] ${msg}`),
     log: (msg) => console.log(`[FR SDK] ${msg}`),
     info: (msg) => console.info(`[FR SDK] ${msg}`),
   };
   ```

   The signature of the interface defaults to the following:

   `(…​msgs: unknown[]) ⇒ void`

   You can pass your own type definition into the Generic if required. For example:

   ```javascript
   // typescript generic example
   type YourAsyncLoggerType = LoggerFunctions<
     (...msgs: unknown[]) => Promise<void>,
     (...msgs: unknown[]) => Promise<void>,
     (...msgs: unknown[]) => Promise<void>,
     (...msgs: unknown[]) => Promise<void>
     >

   const customLoggerWithApiCall: YourAsyncLoggerType = {
     warn: (msg) => yourAsyncLogFunction.warn(`[FR SDK] ${msg}`),
     error: (msg) => yourAsyncLogFunction.error(`[FR SDK] ${msg}`),
     log: (msg) => yourAsyncLogFunction.log(`[FR SDK] ${msg}`),
     info: (msg) => yourAsyncLogFunction.info(`[FR SDK] ${msg}`),
   };
   ```

2. In the SDK configuration of your app, specify the custom logger and required log level:

   ```javascript
   Config.setAsync({
       serverConfig: {
           wellknown: '{edit_cloud_url}/oauth2/realms/root/realms/alpha/.well-known/openid-configuration',
           timeout: '5000'
       },
       logLevel: 'error',
       logger: customLogger,
   });
   ```

   The SDK redirects its logging output to your custom handler.
