Fusion API and Scripts
Got a new add-in to share? Need something specialized to be scripted? Ask questions or share what you’ve discovered with the community.
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Problem with Python built-in logging module

Message 1 of 1
140 Views, 0 Replies

Problem with Python built-in logging module

Hi all,


The Application.log() has very limited functionality, therefore I would like to use the Python built-in logging module.


However, some unexpected problems are noticed:


1. The logging.basicConfig failed to set the format of the log messages. After I executed the code below, I checked the relevant variables in VSCode and it showed that the formatter is still the default format.


The code is as below:

import adsk.core, adsk.fusion,, traceback
import logging
logging.basicConfig(filename='<change to your own path>', 
                    format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',

_app = adsk.core.Application.get()
_ui = _app.userInterface

def run(context):
        logging.debug('This is message 1')
        logging.warning('This is message 2')
        logging.error('This is message 3')
        if _ui:
            _ui.messageBox('Bye bye world')


Screenshot in debugging mode in VSCode. Note that the 'BASIC_FORMAT' is not changed.



2. The second question is quite related to the first one: When I use logging module for different projects (for example, in Script 1 and AddIn 1 in Fusion 360 simultaneously, the filename arguments in logging.basicConfig does not change the log file location.


This results in log messages from different projects end up in the SAME file, despite the fact that I have set different log file locations for them.


This, again, is probably due to the logging.basicConfig not having effect as it supposed to.


The problem is, I have been using logging module in another project (outside Fusion 360) without issue. Hence, I am wondering if this has something to do with the embedded version of Python in Fusion 360 (Maybe something interferes the operation of logging module?).  


Thank you all for your time.

Labels (2)

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th

Autodesk Design & Make Report