Documentation IndexFetch the complete documentation index at: /llms.txtUse this file to discover all available pages before exploring further.
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
开发插件
使用 SDK 的 plugin_logger_handler 从插件内部输出日志信息,可在远程调试时查看,并持久化到守护进程容器日志中
logging
plugin_logger_handler
from collections.abc import Generator from typing import Any from dify_plugin import Tool from dify_plugin.entities.tool import ToolInvokeMessage # 导入 logging 和自定义处理器 import logging from dify_plugin.config.logger_format import plugin_logger_handler # 使用自定义处理器设置日志 logger = logging.getLogger(__name__) logger.setLevel(logging.INFO) logger.addHandler(plugin_logger_handler) class LoggerDemoTool(Tool): def _invoke(self, tool_parameters: dict[str, Any]) -> Generator[ToolInvokeMessage]: # 以不同级别输出日志信息 logger.info("This is an INFO log message.") logger.warning("This is a WARNING log message.") logger.error("This is an ERROR log message.") yield self.create_text_message("Hello, Dify!")
此页面对您有帮助吗?