LogHistory

Summary

The LogHistory class controls whether information about the operation of geoprocessing tools will be written to an external log file.

Discussion

In a script, history logging is activated by default. To disable history logging for a block of code, use the LogHistory class as a function decorator or in a with block as a context manager, and set the log_history parameter to False

The SetLogHistory function can be used to disable history logging for an entire script.

Syntax

LogHistory (log_history)
ParameterExplanationData Type
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

Code sample

LogHistory example 1

Use the LogHistory class as a context manager,

import arcpy

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

Use the LogHistory class as a decorator.

import arcpy

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