> For the complete documentation index, see [llms.txt](https://docs.zipy.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.zipy.ai/zipy-for-mobile/android-setup/custom-logging.md).

# Custom Logging

Logging Messages and Capturing Handled Exceptions enhances app reliability by recording key events and errors during app execution.

### Log Messaage

Logs various types of informational, debug, warning, or error messages to capture events, notifications, or actions within the application.

```swift
import com.zipy.zipyandroid.Zipy;

// Simple message logging
Zipy.logMessage("User completed onboarding");

// With additional context
Zipy.logMessage("Cart updated", cartObject);

// With custom max length
Zipy.logMessage("Custom message", data, 2000);
```

### Log Errors

Logs all the error, providing all the details you pass for debugging. Captures and records error events within your application

```swift
import com.zipy.zipyandroid.Zipy;

// Simple error logging
Zipy.logError("Payment processing failed");

// With error object
Zipy.logError("API error", errorObject);

// With custom max length
Zipy.logError("Database error", error, 2000);

```

### Log Exceptions

Logs exceptions encountered by the application, providing detailed stack traces and context to aid in debugging and troubleshooting. This feature ensures critical data is logged promptly to diagnose and resolve issues.

```swift
import com.zipy.zipyandroid.Zipy;

try {
    // Your code here
} catch (Exception e) {
    // Simple exception logging
    Zipy.logException("Operation failed");

    // With exception details
    Zipy.logException("Failed to process payment", e);

    // With custom max length
    Zipy.logException("Custom error", e, 2000);
}

```

**Note:** For custom logging, if `maxLength` is not provided, it will default to capturing the full length.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.zipy.ai/zipy-for-mobile/android-setup/custom-logging.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
