LogHistory

摘要

LogHistory 类可控制是否将地理处理工具操作的相关信息写入外部日志文件。

说明

在脚本中,默认情况下激活历史记录。 若要禁用代码块的历史日志记录,请将 LogHistory 类用作函数修饰器或在 with 块中用作上下文管理器,并将 log_history 参数设置为 False

SetLogHistory 函数可用于禁用整个脚本的历史日志记录。

语法

 LogHistory (log_history)
参数说明数据类型
log_history

Specifies whether geoprocessing history logging will be enabled and log files created.

  • True—Geoprocessing history logging will be enabled and XML log files will be created in the %AppData%\Esri\ArcGISPro\ArcToolbox\History directory.
  • False—Geoprocessing history logging will not be enabled and XML log files will not be created.
Boolean

代码示例

LogHistory 示例 1

使用 LogHistory 类作为上下文管理器。

import arcpy

with arcpy.LogHistory(False):
    # Geoprocessing tools run in this context will not be logged in the XML log file
    ...
LogHistory 示例 2

使用 LogHistory 类作为修饰符。

import arcpy

@arcpy.LogHistory(False)
def myFunc(input):
    # Geoprocessing tools run in this function will not be logged in the XML log file
    ...