class ArcPyLogger(name=None, prefix_log_file='atools_')[source]#

Bases: object

This class inits a ready to use python logger for ArcGis pro tool. Be sure that arcpy has been imported before using this class. It uses logging under the hood. It writes outputs to a temporary file and to the ArcGis console. The temporary file is removed when the user closes ArcGis.

If you need a logger in an outside module or function, use logging.getLogger(LOGGER_NAME) to get your logger.

  • name (str) – The name of the logger

  • prefix_log_file (str) – The log filename is random, but you can prefix a name. The default value is “{{ name }}_”.


>>> from sertit.arcpy import ArcPyLogger
>>> arcpy_logger = ArcPyLogger(name="MyArcgisTool")
Outputs written to file: C:\Users\bcoriat\AppData\Local\Temp\ArcGISProTemp15788\MyArcgisTool_1bv0c1cl
>>> logger = logging.getLogger("MyArcgisTool")
>>>"Hello World !")
Hello World !


Python must keep a reference to the instantiated object during the execution of your program. That’s why you must init this class once at the top level of your project.

This will not work because Python destroys the object class.

>>> ArcPyLogger(name="MyArcgisTool")
>>> logger = logging.getLogger("MyArcgisTool")
>>>"Hello World !")