Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

How to disable Qt debug messages



  • My project was compiled with Qt 5.4.2, I have recently upgraded it by compiling with 5.10.1

    Since it's compiled with 5.10.1 I have a lot of verbose logs such as :

    [2018.08.17 16:49:18:440]D: Generating leave event for  QWidgetWindow(0x28edb550, name="MainWindowWindow")
    [2018.08.17 16:49:20:404]D: Entering  QWidgetWindow(0x28edb550, name="MainWindowWindow")
    [2018.08.17 16:49:20:772]D: WM_MOUSELEAVE for  QWidgetWindow(0x28edb550, name="MainWindowWindow")  previous window under mouse =  QWidgetWindow(0x28edb550, name="MainWindowWindow")  tracked window = QWidgetWindow(0x28edb550, name="MainWindowWindow")
    [2018.08.17 16:49:20:777]D: Generating leave event for  QWidgetWindow(0x28edb550, name="MainWindowWindow")
    

    I have disabled it by writing :

    *.debug = false
    

    in Rules in the qtlogging.ini file.

    It works well but I don't have my own qDebug messages anymore. How can I disable Qt framework messages debug only ?



  • @bam500
    I shall be interested for an alternative answer here, because my understanding is that the internals just use qDebug() like you do, and if you want your own you will get theirs automatically too....



  • @JonB Mhhh ok, well a workaround would be to change each debug message into warning or info... But it means a lot of changes... Yes an alternative answer would be appreciated!


  • Moderators

    there is DEFINES += QT_NO_DEBUG_OUTPUT that you can add to your pro file. It stops any code with qDebug() in it from being executed.

    You can even condition it, so that for example, you get debug output during debug builds, but non in release.

    CONFIG(release, debug|release):DEFINES += QT_NO_DEBUG_OUTPUT
    

    however, be careful.
    something like

    QFile f(/path/patch/etc),
    qDebug() << f.open();
    

    may very well break your code.



  • @J.Hilk
    I don't understand how this helps? The problem is that there are existing qDebug() statements in internal Qt code, which the user does not want output, and explicit qDebug() in his own code, which he does want output. That's why I wrote my post above.


  • Moderators

    @JonB
    oh, you're right, I may have mussunderstood the op.


Log in to reply