The AddMessage
will add a message to the geoprocessing job message queue:
jobs/ja861064b634648f1be2371e2307c6112?f=json
For general logging, I use python logging:
import logging
and make sure the formatter has a process id:
formatter = logging.Formatter('%(asctime)s p%(process)s {%(pathname)s:%(lineno)d} %(levelname)s |-| %(message)s')
# Set up logging
logfilepath = os.path.join(tempfile.gettempdir(),'example.log')
logger = logging.getLogger('example_logger')
logger.setLevel(logging.DEBUG)
logger.handlers = []
formatter = logging.Formatter('%(asctime)s p%(process)s {%(pathname)s:%(lineno)d} %(levelname)s |-| %(message)s')
fh = logging.FileHandler(logfilepath)
fh.setFormatter(formatter)
logger.addHandler(fh)
ch = logging.StreamHandler()
ch.setLevel(logging.DEBUG)
ch.setFormatter(formatter)
logger.addHandler(ch)
logger.info('example script start...')
fh.flush()
logger.debug('Importing ArcPy...')
import arcpy
logger.debug('Importing ArcPy Import Complete')