2/2/2023 0 Comments Arcgis file handler errortry:Ī simple test script: errorLog = r'd:\log.txt'ĮrrorMsg.write("%s,%s\n" % (errorLog,filePath)) Lastly you can use logger.exception in an except block which will give you a logging message at ERROR level, and also dump the stacktrace to the log. Which will write the messages of levels info and above through arcpy to the processing window, and all messages from debug and above to the log file specified with the format specified above (see the documentation for other formatting options). Logger.critical("A critical error message") You can then use the handler with a standard python logging object: logger = logging.getLogger("LoggerName")įormatter = logging.Formatter("%(levelname)-8s %(message)s")Īnd then you can write log messages like so: bug("A debug message") Super(ArcPyLogHandler, self).emit(record) import loggingĬlass ArcPyLogHandler():Ĭustom logging class that bounces messages to the arcpy tool window as well The idea being that you can use the standard Python logging framework and also have the messages reflected back to ArcGIS through the arcpy messages. I've written a python log handler that I'm more than happy to share.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |