> ## Documentation Index
> Fetch the complete documentation index at: https://agno-v2.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Custom Logging

> Configure the default agno.utils.log logger with a custom Python logger.

Configure the default `agno.utils.log` logger with a custom Python logger by calling `configure_agno_logging()`.

> [!WARNING]
>
> The source passes only `custom_default_logger`, which configures the default `agno.utils.log` logger. Agent, team, and workflow operations use separate loggers. Pass the custom logger to all four parameters to route those operation logs through it too.

```python custom_logging.py theme={null}
"""
Custom Logging
=============================

Example showing how to use a custom logger with Agno.
"""

import logging

from agno.agent import Agent
from agno.utils.log import configure_agno_logging, log_info


def get_custom_logger():
    """Return an example custom logger."""
    custom_logger = logging.getLogger("custom_logger")
    handler = logging.StreamHandler()
    formatter = logging.Formatter("[CUSTOM_LOGGER] %(levelname)s: %(message)s")
    handler.setFormatter(formatter)
    custom_logger.addHandler(handler)
    custom_logger.setLevel(logging.INFO)  # Set level to INFO to show info messages
    custom_logger.propagate = False
    return custom_logger


# Get the custom logger we will use for the example.
custom_logger = get_custom_logger()

# Configure Agno to use our custom logger. It will be used for all logging.
configure_agno_logging(custom_default_logger=custom_logger)

# Every use of the logging function in agno.utils.log will now use our custom logger.
log_info("This is using our custom logger!")

# Now let's setup an Agent and run it.
# All logging coming from the Agent will use our custom logger.
# ---------------------------------------------------------------------------
# Create Agent
# ---------------------------------------------------------------------------
agent = Agent()

# ---------------------------------------------------------------------------
# Run Agent
# ---------------------------------------------------------------------------
if __name__ == "__main__":
    agent.print_response("What can I do to improve my sleep?")
```

## Run the Example

<Snippet file="create-venv-step.mdx" />

**1. Install dependencies**

```bash theme={null}
uv pip install -U agno openai
```

**2. Export your OpenAI API key**

```bash Mac/Linux theme={null}
export OPENAI_API_KEY="your_openai_api_key_here"
```

```bash Windows theme={null}
$Env:OPENAI_API_KEY="your_openai_api_key_here"
```

**3. Configure every Agno logger**

Replace `configure_agno_logging(custom_default_logger=custom_logger)` with `configure_agno_logging(custom_default_logger=custom_logger, custom_agent_logger=custom_logger, custom_team_logger=custom_logger, custom_workflow_logger=custom_logger)` in the saved file.

**4. Run the example**

Save the code above as `custom_logging.py`, then run:

```bash theme={null}
python custom_logging.py
```

Full source: [cookbook/02\_agents/14\_advanced/custom\_logging.py](https://github.com/agno-agi/agno/blob/v3.0.4/cookbook/02_agents/14_advanced/custom_logging.py)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.