******************** Log Messages In Task ******************** Problem ======= You want to write task messages to a persistent log file. Solution ======== Get the reference to the Log interface by calling :py:meth:`get_property` on the task and passing in :py:class:`TaskProperties.LOGGER `. .. literalinclude:: ..\..\..\code\HowTos\TaskLogging.py :language: python :linenos: :dedent: 8 :lines: 7 With an instance of the Log interface, all log methods are written to the standard host log files by default. To view the log files, see :ref:`viewing log files`. .. literalinclude:: ..\..\..\code\HowTos\TaskLogging.py :language: python :linenos: :dedent: 8 :lines: 8-10 .. literalinclude:: ..\..\..\code\HowTos\TaskLogging.py :language: python :linenos: :lines: 1-4,4,5-11,11,12-18 Discussion ========== Logging can be important for debugging, tracing, and post-mortem analysis. The Log interface provides "free" logging within tasks. The main advantage to using the Log interface versus a custom logging mechanism is that Log is tightly integrated with the existing logging infrastructure. For instance, right clicking on a task within the monitoring applications displays the user log messages in the same logs as the host. See Also ======== Reference """"""""" * :py:obj:`LOGGER ` Other Resources """"""""""""""" * :ref:`viewing log files`