Viewing tool execution history
Each time you run a geoprocessing tool, information about the tool and its parameters is saved. This saved information is referred to as geoprocessing history. This historical information is very useful for determining how data was created and can be used to rerun a process. This historical information is stored in three places:
- The Results window. This is the first place you want to look for a history of what tools you've run and their results.
- A history log file that contains information about each geoprocessing operation. The information contained in the log file is essentially the same as that found in the Results window.
- The metadata of a tool's output data.
Information about tools run within models is not recorded.
For script tools and stand-alone scripts (scripts run outside of an ArcGIS application—from the operating system prompt, for example), you can enable history logging using the SetLogHistory function, as shown in the following Python code snippet:
import arcpy
arcpy.SetLogHistory(True)
This will log each tool run from within the script.
Enabling history logging
To enable the writing of history log files, do the following:
- From the Standard toolbar, click Geoprocessing > Geoprocessing Options.
- Enable (check) the Log geoprocessing operations to a log file check box.
History log files
Where history log files are written
There is one log file for each application (such as ArcMap or ArcCatalog) session. A session is defined by all the work performed from the time you open the application to the time you exit.
On Windows XP, the log files are written to C:\Documents and Settings\<user name>\Application Data\ESRI\Desktop10.1\ArcToolbox\History.
On Windows Vista and Windows 7, the log files are written to C:\Users\<user name>\AppData\(Local or LocalLow or Roaming)\ESRI\Desktop10.1\ArcToolbox\History.
The name of the log file contains the date and time when the application was opened: H<month><day><year>_<hour><minute><second>.xml.
Log file contents
The log file is an Extensible Markup Language (XML) file and is best viewed in an Internet browser such as Internet Explorer. You can drag and drop the file into your browser or, from your browser, click File > Open. The illustration below shows a log file viewed in Internet Explorer.
Information about an individual tool execution is found between the <ResultView> and </ResultView> tags. If you're viewing the log file in a browser, you can collapse and expand tags by clicking the - or a +, as shown below.
The structure and contents within each tag are mostly self-explanatory. Notes about some of the tags follow:
<ToolSource>
This is the catalog path to the toolbox containing the tool.
<Parameter>
The parameter tag has two attributes, Name and Type.
- Label is the label of the parameter as it appears in the tool's dialog box.
- Type contains one of three types:
- Dataset means the value is the catalog path to a dataset on disk.
- Layer means the value is the name of a layer in the ArcMap table of contents. The dataset that the layer references can be found in the <LayerInfo> tag.
- Scalar contains all other values, such as strings, numbers, or linear units.
<LayerInfo>
For every layer used in tool execution, there will be a <Layer> tag in <LayerInfo>. The <Layer> tag has the layer name as an attribute and the catalog path to the dataset used by the layer.
<Environments>
Within the <Environments> tag, there are individual <Environment> tags containing the environment settings during the time of tool execution. Each <Environment> tag has a name attribute containing the environment name and the environment setting. Only environment settings that contain values are listed. That is, there will not be an <Environment> for settings containing blank values.
<Errors>
If there were errors during tool execution, they will be listed here. Internal system errors will be listed here as well, unlike messages written to the progress dialog box or results in the Results window.
Geoprocessing history in Metadata
Each geoprocessing tool that creates new output data or updates the input data will add metadata about the execution of the geoprocessing tool, which includes the tool name, its location, and the parameters used.
Metadata for a dataset is viewed by right-clicking a dataset in the Catalog window or ArcCatalog and choosing Item Description.
For the Item Description window to display metadata, you must first choose a metadata style that will display geoprocessing history. To change the metadata style, follow the instructions in Choosing a metadata style and set the style to anything except Item Description (the default style).
After changing the metadata style, you can right-click a dataset and choose Item Description. There will be a section in the Item Description window for geoprocessing.