class ansys.mapdl.core.logging.Logger(level=10, to_file=False, to_stdout=True, filename='pymapdl.log')

Logger used for each Pymapdl session.

This class allows you to add handlers to the logger to output to a file or standard output.

levelint, optional

Logging level to filter the message severity allowed in the logger. The default is logging.DEBUG.

to_filetbool, optional

Write log messages to a file. The default is False.

to_stdoutbool, optional

Write log messages into the standard output. The default is True.

filenamestr, optional

Name of the file where log messages are written to. The default is None.


Demonstrate logger usage from an instance mapdl. This is automatically created when creating an Mapdl instance.

>>> from ansys.mapdl.core import launch_mapdl
>>> mapdl = launch_mapdl(loglevel='DEBUG')
>>>'This is a useful message')
INFO -  -  <ipython-input-24-80df150fe31f> - <module> - This is LOG debug message.

Import the global pymapdl logger and add a file output handler.

>>> import os
>>> from ansys.mapdl.core import LOG
>>> file_path = os.path.join(os.getcwd(), 'pymapdl.log')
>>> LOG.log_to_file(file_path)


Logger.add_child_logger(sufix[, level])

Add a child logger to the main logger.


This just redirect the output of an exception to the logger.

Logger.add_instance_logger(name, mapdl_instance)

Create a logger for a MAPDL instance.

Logger.log_to_file([filename, level])

Add file handler to logger.


Add standard output handler to the logger.


Change the log level of the object and the attached handlers.