Search code examples
pythonc++py2exeautodesklog4cplus

Exclude (or disable) log4cplus warnings when compiling or running a PyQT4 GUI app?


I built a little GUI app with QtDesigner in Python and I passed the app along to a few people in my team which are using Autodesk 360 + Autocad.

My app use the QFileDialog command to get filenames, which is known to have a bug when Autodesk 360 is installed on the machine: link 1, link2 .

The bug: the console always returns the following errors when a file dialog is called:

log4cplus:ERROR No appenders could be found for logger (AdSyncNamespace).
log4cplus:ERROR Please initialize the log4cplus system properly.

The error is not critical as it doesn't change the processing, but I don't want any error message to pop like that.

Considering we will often distribute the app to people using Autodesk products daily and that the bug does not look like something that will be corrected soon, is it possible to ignore this error so that it does not show in the console ? Maybe by ignoring something during the build with py2exe... I don't know where to search. Thanks !


Solution

  • Disclaimer: not a complete answer but an extended track of the problem.

    The problem is that at least one of components of Autodesk 360, likely AdSyncNamespace.dll, uses log4cplus library but hasn't provided a correct configuration for it.

    According to log4cplus:ERROR in python when calling for tkinter file dialog even @wilx , the author of log4cplus didn't know back in 2013, how to correctly fix the problem.

    By default, log4cplus requires a java style property file to load configuration from, so I suppose, AdSyncNamespace.dll may have such a configuration, either in a file, or stored in a Windows registry key. You may search files containing log4cplus. strings in your Autodesk installation folder, and track what registry keys are accessed using See what files/registry keys are being accessed by application in Windows

    Certainly, this all might seem quite boring and you might prefer a simpler solution. A simpler solution would be to redirect STDERR of your app to nowhere as described here or here but this might be not appropriate for your program since it uses console for output.

    Update: you may try to set environment variable LOG4CPLUS_LOGLOG_QUIETMODE=false in your app or even globally, and check if it helps. Also if you don't need STDERR and perform all "valid" console output through STDOUT, then you may try to simply close STDERR or redirect it to nul as described in the links provided above.