You can provide your own loggers to Agno, to be used instead of the default ones. This can be useful if you need your system to log in any specific format.

Example

import logging

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


# Setting up a 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


# 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!")

# Setting up an example Agent
agent = Agent()

# Now let's setup an example Team and run it.
# All logging will use our custom logger.
team = Team(members=[agent])
team.print_response("What can I do to improve my sleep?")

Multiple Loggers

Notice that you can also configure different loggers for your Agents, Teams and Workflows:
configure_agno_logging(
    custom_default_logger=custom_agent_logger,
    custom_agent_logger=custom_agent_logger,
    custom_team_logger=custom_team_logger,
    custom_workflow_logger=custom_workflow_logger,
)

Using Named Loggers

As it’s conventional in Python, you can also provide custom loggers just by setting loggers with specific names. This is useful if you want to set them up using configuration files.
  • agno.agent will be used for all Agent logs
  • agno.team will be used for all Team logs
  • agno.workflow will be used for all Workflow logs
These loggers will be automatically picked up if they are set.