A programming framework for agentic AI
docs: Add logging instructions for AgentChat and enhance core logging guide (#5655)
Eric Zhu08c82e4c6f3d
diff --git a/python/packages/autogen-core/docs/src/user-guide/agentchat-user-guide/index.md b/python/packages/autogen-core/docs/src/user-guide/agentchat-user-guide/index.mdindex b7d124f9e..73095d65b 100644--- a/python/packages/autogen-core/docs/src/user-guide/agentchat-user-guide/index.md+++ b/python/packages/autogen-core/docs/src/user-guide/agentchat-user-guide/index.md@@ -37,6 +37,12 @@ Build your first agentStep-by-step guide to using AgentChat, learn about agents, teams, and more:::+:::{grid-item-card} {fas}`wrench;pst-color-primary` Custom Agents+:link: ./custom-agents.html++Create your own agents with custom behaviors+:::+:::{grid-item-card} {fas}`sitemap;pst-color-primary` Selector Group Chat:link: ./selector-group-chat.html@@ -55,16 +61,16 @@ Multi-agent coordination through a shared context and localized, tool-based seleGet started with Magentic-One:::-:::{grid-item-card} {fas}`code;pst-color-primary` Examples-:link: ./examples/index.html+:::{grid-item-card} {fas}`brain;pst-color-primary` Memory+:link: ./memory.html-Sample code and use cases+Add memory capabilities to your agents:::-:::{grid-item-card} {fas}`truck-moving;pst-color-primary` Migration Guide-:link: ./migration-guide.html+:::{grid-item-card} {fas}`file;pst-color-primary` Logging+:link: ./logging.html-How to migrate from AutoGen 0.2.x to 0.4.x.+Log traces and internal messages::::::{grid-item-card} {fas}`save;pst-color-primary` Serialize Components@@ -73,10 +79,16 @@ How to migrate from AutoGen 0.2.x to 0.4.x.Serialize and deserialize components:::-:::{grid-item-card} {fas}`brain;pst-color-primary` Memory-:link: ./memory.html+:::{grid-item-card} {fas}`code;pst-color-primary` Examples+:link: ./examples/index.html-Add memory capabilities to your agents+Sample code and use cases+:::++:::{grid-item-card} {fas}`truck-moving;pst-color-primary` Migration Guide+:link: ./migration-guide.html++How to migrate from AutoGen 0.2.x to 0.4.x.:::::::@@ -101,7 +113,6 @@ tutorial/agentstutorial/teamstutorial/human-in-the-looptutorial/termination-tutorial/state```@@ -116,6 +127,7 @@ selector-group-chatswarmmagentic-onememory+loggingserialize-components```diff --git a/python/packages/autogen-core/docs/src/user-guide/agentchat-user-guide/logging.md b/python/packages/autogen-core/docs/src/user-guide/agentchat-user-guide/logging.mdnew file mode 100644index 000000000..5934cf304--- /dev/null+++ b/python/packages/autogen-core/docs/src/user-guide/agentchat-user-guide/logging.md@@ -0,0 +1,26 @@+# Logging++AutoGen uses Python's built-in [`logging`](https://docs.python.org/3/library/logging.html) module.++To enable logging for AgentChat, you can use the following code:++```python+import logging++from autogen_agentchat import EVENT_LOGGER_NAME, TRACE_LOGGER_NAME++logging.basicConfig(level=logging.WARNING)++# For trace logging.+trace_logger = logging.getLogger(TRACE_LOGGER_NAME)+trace_logger.addHandler(logging.StreamHandler())+trace_logger.setLevel(logging.DEBUG)++# For structured message logging, such as low-level messages between agents.+event_logger = logging.getLogger(EVENT_LOGGER_NAME)+event_logger.addHandler(logging.StreamHandler())+event_logger.setLevel(logging.DEBUG)+```++To enable additional logs such as model client calls and agent runtime events,+please refer to the [Core Logging Guide](../core-user-guide/framework/logging.md).\ No newline at end of filediff --git a/python/packages/autogen-core/docs/src/user-guide/core-user-guide/framework/logging.md b/python/packages/autogen-core/docs/src/user-guide/core-user-guide/framework/logging.mdindex b261e8bbe..55e858978 100644--- a/python/packages/autogen-core/docs/src/user-guide/core-user-guide/framework/logging.md+++ b/python/packages/autogen-core/docs/src/user-guide/core-user-guide/framework/logging.md@@ -22,9 +22,23 @@ from autogen_core import TRACE_LOGGER_NAMElogging.basicConfig(level=logging.WARNING)logger = logging.getLogger(TRACE_LOGGER_NAME)+logger.addHandler(logging.StreamHandler())logger.setLevel(logging.DEBUG)```+To enable structured logging, you can use the following code:++```python+import logging++from autogen_core import EVENT_LOGGER_NAME++logging.basicConfig(level=logging.WARNING)+logger = logging.getLogger(EVENT_LOGGER_NAME)+logger.addHandler(logging.StreamHandler())+logger.setLevel(logging.INFO)+```+### Structured loggingStructured logging allows you to write handling logic that deals with the actual events including all fields rather than just a formatted string.