Skip to content

Commit 7a5b5c4

Browse files
Add instructions on how to surface ADK logs (#2402)
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
1 parent ebfc9d3 commit 7a5b5c4

File tree

1 file changed

+33
-1
lines changed

1 file changed

+33
-1
lines changed

agents/agent_engine/memory_bank/get_started_with_memory_bank_on_adk.ipynb

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,39 @@
203203
"os.environ[\"GOOGLE_CLOUD_LOCATION\"] = LOCATION"
204204
]
205205
},
206+
{
207+
"cell_type": "markdown",
208+
"metadata": {},
209+
"source": [
210+
"## (Optional) Set up logging\n",
211+
"To surface ADK logs in your notebook, you may need to configure the logging level of ADK's logger."
212+
]
213+
},
214+
{
215+
"cell_type": "code",
216+
"execution_count": null,
217+
"metadata": {},
218+
"outputs": [],
219+
"source": [
220+
"import logging\n",
221+
"import sys\n",
222+
"\n",
223+
"# Set up a general handler for all logs to be printed in your Colab output.\n",
224+
"# We'll set the overall level to INFO.\n",
225+
"logging.basicConfig(\n",
226+
" level=logging.INFO,\n",
227+
" format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',\n",
228+
" stream=sys.stdout\n",
229+
")\n",
230+
"\n",
231+
"# Get the specific logger used by ADK.\n",
232+
"adk_logger = logging.getLogger('google_adk')\n",
233+
"\n",
234+
"# Set its level to DEBUG to ensure you capture ALL messages from the SDK,\n",
235+
"# even if the general level is higher (like INFO).\n",
236+
"adk_logger.setLevel(logging.DEBUG)"
237+
]
238+
},
206239
{
207240
"cell_type": "markdown",
208241
"metadata": {
@@ -229,7 +262,6 @@
229262
"from google.adk.agents import LlmAgent\n",
230263
"from google.adk.runners import Runner\n",
231264
"from google.adk.sessions import InMemorySessionService\n",
232-
"from google.genai import types\n",
233265
"from google.genai.types import Content, Part\n",
234266
"\n",
235267
"APP_NAME = \"memory_example_app\"\n",

0 commit comments

Comments
 (0)