Write logs to a file

1068
1
02-14-2018 05:32 AM
akshayloya
Occasional Contributor II

Hi,

I have made a model builder tool. I need to save the logs of this tool in a log file on my D drive of system. Any idea how it can be automated ?

Secondly can I call some other windows schedule event once the model is executed ?

Any help or insights will be much appreciated.

- Akshay

0 Kudos
1 Reply
curtvprice
MVP Esteemed Contributor

You can set up a python script to run the model (output goes to stdout)

# Python script to run model
import arcpy
arcpy.ImportToolbox(r"\\path\foo.tbx","bar")
arcpy.bar.MyModel()

And launch the python script to run the python script (which runs the model) and capture the output:

:: bat script to run python script and catch output
echo Model run: %DATE%%TIME% >> D:\logs\mymodel.txt
C:\Python27\ArcGIS10.5\python.exe batchpy.py 2>&1 >> D:\logs\mymodel.txt‍‍‍
:: do next thing when model is done
echo Doing next thing >> D:\logs\mymodel.txt
cmd /c D:\logs\otherthing.bat