Turning on/off geoprocessing history via arcpy?

5865
14
08-08-2011 03:48 PM
ChrisSnyder
Regular Contributor III
Anyone know how to turn off the geoprocessing history in ArcGIS v10.0 (arcpy) via Python?

Seems like ESRI got rid of the gp.loghistory setting, and I can't seem to find a way to turn it off in arcpy...
Tags (2)
14 Replies
JohnYaist1
Esri Contributor
Try using the arcpy.SetLogHistory function.
0 Kudos
ChrisSnyder
Regular Contributor III
I'm not sure that actually does anything... For example:

>>> arcpy.env.cellSize
u'MAXOF'

>>> arcpy.SetLogHistory
Traceback (most recent call last):
  File "<interactive input>", line 1, in <module>
AttributeError: 'module' object has no attribute 'SetLogHistory'

>>> arcpy.env.SetLogHistory
Traceback (most recent call last):
  File "<interactive input>", line 1, in <module>
AttributeError: 'GPEnvironment' object has no attribute 'SetLogHistory'

>>> arcpy.env.iHateArcPy
Traceback (most recent call last):
  File "<interactive input>", line 1, in <module>
AttributeError: 'GPEnvironment' object has no attribute 'iHateArcPy'

>>> arcpy.env.iHateArcPy = True

>>> print arcpy.env.iHateArcPy
True


It ain't necessarily so...
0 Kudos
JakeSkinner
Esri Esteemed Contributor
Try:

arcpy.logHistory = False
0 Kudos
ChrisSnyder
Regular Contributor III
None of the following methods turn of the .xml history logging (for me, stored under C:\Users\csny490\AppData\Roaming\ESRI\Desktop10.0\ArcToolbox\History):

arcpy.loghistory = False
arcpy.logHistory = False
arcpy.env.loghistory = False
arcpy.env.logHistory = False
arcpy.setLogHistory = False
arcpy.SetLogHistory = False
arcpy.env.setLogHistory = False
arcpy.env.SetLogHistory = False

Curiously, you can also seem to set any method you think up. For example:

>>> arcpy.whyDoesntThisWork = False
>>> print arcpy.whyDoesntThisWork
False

Which gives the false sense that some of these settings are "working" when in fact they are invalid methods and aren't actually serving any purpose.

Could it be that the history log setting in v10 via arcpy is just a placebo now and there is no way to tun it off? Seems that tuning it off via ArcMap (ArcMap > Geoprocessing > Geoprocessing Options) only turns off the logging when the tool is run via ArcMap. I would like to turn this setting off for all my scripts, but seemingly can't do that anymore in v10 arcpy... Yargh!

Note that:

import arcgisscripting
gp = arcgisscripting.create(9.3)
gp.loghistory = False

still works to stop history logging in v10.0.

In my experience with the old logging system (that use .tbx files), the larger the history file becomes the slower the tools execute. Seems that in v10 (9.3 too I think) the .xml files are created anew ever hour, but regardless, it is still possible to issue thousands of tool commands in an hour - each tool execution making the hourly .xml file larger, and the entire history fiolder larger as well.

Please ESRI: We need a way to turn the geoprocessing history log off via arcpy!
0 Kudos
DavidWynne
Esri Contributor
Hi Chris,
It's not directly on arcpy at 10.0 (at 10.1 there will be SetLogHistory/GetLogHistory functions), but you can set it through arcpy.gp like below.

import arcpy
arcpy.gp.loghistory = False #turn it off



With regards to setting 'new' properties on arcpy. This is really just how Python works, there isn't a distinction between attributes in a class or setting them later in the code. You'll see this in Python standard libraries too, or even a class you might create yourself. 

Generally speaking in arcpy, if you don't see a property on arcpy, or any of it's classes and modules, it's not there (Describe being an exception).


-Dave
ChrisSnyder
Regular Contributor III
Thanks for the info David. I'm looking forward to 10.1...
0 Kudos
ChrisSnyder
Regular Contributor III
I found it's actually:

arcpy.gp.logHistory = False
and not
arcpy.gp.loghistory = False


(case sensitivity of v10 matters even though it's from gp... but I guess arcpy.gp)

Anyway, go to find that's why I had 4GB of history .xml files in my profile!
0 Kudos
DanMarrier
New Contributor II
Unfortunately, 'arcpy.gp.logHistory = False' does nothing to prevent geoprocessing steps from being written to ESRI metadata (at least when run in an IDE... haven't tested from an ArcMap session yet).  There is a button one can add to ArcCatalog to allow a manual erase of this geoprocessing history, but I have found nothing that indicates the function(s) it corresponds to in the arcpy module.
ChrisSnyder
Regular Contributor III
Agreed - All these bells and whistles are quite annoying - especially when you can't turn them off! Especially annoying when they affect (even just a little) geoprocessing performance...

Verified: Using arcpy.gp.logHistory = False does keep the .xml geoprocessing history files at bay (for Windows 7 stored in C:\Users\<username>\AppData\Roaming\ESRI\Desktop10.0\ArcToolbox\History)
However, there doesn't appear to be anyway from writting that dribble to the dataset metadata.

SUPER LAME!!!
0 Kudos