Error logging

Chat SDK records by default (errorLogger) all Chat SDK and PubNub-specific errors in the current session - from the moment you initialize chat till the time you close the app.

These logs can help you understand what went wrong in your app to debug, fix issues, and prevent future errors.

You can download a TXT file containing all session-related errors with our dedicated method. The file contains a JSON that you can format to make it easier to read.

Each session log starts with the PUBNUB_INTERNAL_ERROR_LOGGER constant, a session ID, and a list of app errors. Each error has a unified structure:

  • key listing the method that caused the error and the object on which it was called.
  • error containing the exact error message.
  • thrownFunctionArguments showing the method arguments the error relates to.

In this example, an error is returned when you try to retrieve channel details without providing the channel ID that is required in this Chat SDK method.

{
"PUBNUB_INTERNAL_ERROR_LOGGER_1691586109386":[
{
"key":"Chat.getChannel",
"error":"ID is required",
"thrownFunctionArguments":{
"0":""
}
}
]
}

In this example, you want to create a public channel, and the channel ID is too long as it exceeds the 92 UTF-8 characters allowed by PubNub.

{
"PUBNUB_INTERNAL_ERROR_LOGGER_1691586109386":[
{
"key":"Chat.createPublicConversation",
"error":{
"name":"Error",
"message":"PubNub call failed, check status for details",
"status":{
"error":true,
"operation":"PNSetChannelMetadataOperation",
"statusCode":400,
"errorData":{
"status":400,
"error":{
"message":"Invalid request input.",
show all 36 lines

Download error log

Use this method for web apps to download a file containing session-relevant errors that occurred in your chat app.

Method signature

This method has the following signature:

chat.downloadDebugLog(): void

Input

This method doesn't take any parameters.

Output

TypeDescription
voidMethod does not return any value. It allows you to add additional logic and download a text file with logs from a web app.

Basic usage

Download the current error log.

chat.downloadDebugLog()
Last updated on