Create a log file from Geoprocessing service

08-30-2018 12:44 AM
New Contributor III

I am using a ArcPy tool update some feature in ArcGIS desktop, also generating a log file to update some of the tasks, the script running fine in the desktop. When publishing it as a service to call the same from ArcGIS server, the log file is not created in the given path, but the process was completed successfully and the results are updated. What would be the correct way for creating a log file(or any other file) from a geoprocessing service?

0 Kudos
3 Replies
Esri Regular Contributor

You might want to ask this question in the Python community:


This space is more geared towards questions about the ArcGIS API for JavaScript.



Esri Frequent Contributor

File based outputs of GP services will be written to the scratch directory by design: C:\arcgisserver\directories\arcgisjobs\<service>\<jobID>\

You can write the log to that directory using the arcpy.env.scratchFolder environment variable:


logPath = os.path.join(arcpy.env.scratchFolder,"gplog.log")

This is challenging as you then need to know the job ID of the job to retrieve the results. You may be able to write to a table in a database, though. What do you need the log file for? What if you just return messages within the script:


arcpy.AddMessage("Successfully <did whatever>")

If you set the GP service to return Info messages, the client will be able to retrieve the messages.

New Contributor III

Thanks for your suggestions guys. I couldn't make that work but my workaround is migrating the arcpy file itself to arcgis server instead of publishing it as a service. Now it's working fine and the log file is also created successfully.

0 Kudos