Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. qDebug() doesn't show messages in Qt Creator/Application Output
Forum Updated to NodeBB v4.3 + New Features

qDebug() doesn't show messages in Qt Creator/Application Output

Scheduled Pinned Locked Moved Solved Qt Creator and other tools
19 Posts 5 Posters 212 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Christian EhrlicherC Offline
    Christian EhrlicherC Offline
    Christian Ehrlicher
    Lifetime Qt Champion
    wrote last edited by
    #6

    I would guess there is an external logging config somewhere. Please read https://doc.qt.io/qt-6/qloggingcategory.html#configuring-categories

    Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
    Visit the Qt Academy at https://academy.qt.io/catalog

    JonBJ 1 Reply Last reply
    0
    • Christian EhrlicherC Christian Ehrlicher

      I would guess there is an external logging config somewhere. Please read https://doc.qt.io/qt-6/qloggingcategory.html#configuring-categories

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote last edited by JonB
      #7

      @Christian-Ehrlicher
      To be fair the OP reports

      Running in debug mode, qDebug() doesn't show messages in Qt Creator/Application Output, but when running a terminal manually, it shows.

      Assuming the executable is compiled the same (e.g. either debug or release) whether it is run from Creator or from a terminal how would some "external logging config" allow for output to terminal in the latter case but not the former? Unless you mean the environment differs such that this logging file is picked up when running from Creator but not outside?

      @jronald
      You might verify that if compiled for release instead the behaviour is the same? Also if executed from Creator but as Run rather than Debug does that make any difference?

      jronaldJ 1 Reply Last reply
      0
      • Axel SpoerlA Axel Spoerl

        Hi and welcome @jronald !
        please add qInfo() << QT_VERSION_STR << QT_DEBUG and post the output here.
        Cheers
        Axel

        jronaldJ Offline
        jronaldJ Offline
        jronald
        wrote last edited by
        #8

        @Axel-Spoerl said in qDebug() doesn't show messages in Qt Creator/Application Output:

        Hi and welcome @jronald !
        please add qInfo() << QT_VERSION_STR << QT_DEBUG and post the output here.
        Cheers
        Axel

        #include <QDebug>
        #include <QtVersion>
        
        int main()
        {
        #ifdef QT_DEBUG
            qDebug() << "Test123";
            qInfo() << QT_VERSION_STR;
        #else
            qDebug() << "Test456";
            qInfo() << QT_VERSION_STR;
        #endif
            return 0;
        }
        

        can't output QT_DEBUG as QT_VERSION_STR does, so do it as above.
        Still no output in "Qt Creator/Application Output", but when run it in a terminal manually, it outputs as below:

        Test123
        6.10.1
        
        1 Reply Last reply
        0
        • JonBJ JonB

          @Christian-Ehrlicher
          To be fair the OP reports

          Running in debug mode, qDebug() doesn't show messages in Qt Creator/Application Output, but when running a terminal manually, it shows.

          Assuming the executable is compiled the same (e.g. either debug or release) whether it is run from Creator or from a terminal how would some "external logging config" allow for output to terminal in the latter case but not the former? Unless you mean the environment differs such that this logging file is picked up when running from Creator but not outside?

          @jronald
          You might verify that if compiled for release instead the behaviour is the same? Also if executed from Creator but as Run rather than Debug does that make any difference?

          jronaldJ Offline
          jronaldJ Offline
          jronald
          wrote last edited by
          #9

          @JonB said in qDebug() doesn't show messages in Qt Creator/Application Output:

          You might verify that if compiled for release instead the behaviour is the same? Also if executed from Creator but as Run rather than Debug does that make any difference?

          I've tried debug only.
          I tried release just now, same as debug, no output in "Qt Creator/Application Output", output in a terminal.

          1 Reply Last reply
          0
          • jronaldJ Offline
            jronaldJ Offline
            jronald
            wrote last edited by
            #10

            If check "Projects/Run Settings/Run in terminal", it will show the messages by qDebug() and qInfo().

            1 Reply Last reply
            0
            • jronaldJ Offline
              jronaldJ Offline
              jronald
              wrote last edited by
              #11

              It works after adding QT_ASSUME_STDERR_HAS_CONSOLE=1 in "Projects/Run Settings/Environment".
              But I don't know why.

              jronaldJ 1 Reply Last reply
              0
              • jronaldJ jronald

                It works after adding QT_ASSUME_STDERR_HAS_CONSOLE=1 in "Projects/Run Settings/Environment".
                But I don't know why.

                jronaldJ Offline
                jronaldJ Offline
                jronald
                wrote last edited by jronald
                #12

                https://bbs.archlinux.org/viewtopic.php?id=259035

                Log from Qt Creator is redirected to systemd journal.
                Maybe Arch Linux maintainers should change some build flag(s) for Qt Creator.

                I've checked journalctl, the outputs are there.
                It should be the cause of archlinux, not intuitive, and leaves unnecessary footprints.

                JonBJ 1 Reply Last reply
                0
                • jronaldJ jronald

                  https://bbs.archlinux.org/viewtopic.php?id=259035

                  Log from Qt Creator is redirected to systemd journal.
                  Maybe Arch Linux maintainers should change some build flag(s) for Qt Creator.

                  I've checked journalctl, the outputs are there.
                  It should be the cause of archlinux, not intuitive, and leaves unnecessary footprints.

                  JonBJ Offline
                  JonBJ Offline
                  JonB
                  wrote last edited by
                  #13

                  @jronald
                  That looks like it to me for Arch, well found! I can only say I always have Qt from Ubuntu repo and it works, you don't need to set an environment variable.

                  jronaldJ 1 Reply Last reply
                  1
                  • jronaldJ jronald has marked this topic as solved
                  • JonBJ JonB

                    @jronald
                    That looks like it to me for Arch, well found! I can only say I always have Qt from Ubuntu repo and it works, you don't need to set an environment variable.

                    jronaldJ Offline
                    jronaldJ Offline
                    jronald
                    wrote last edited by jronald
                    #14

                    @JonB said in qDebug() doesn't show messages in Qt Creator/Application Output:

                    I can only say I always have Qt from Ubuntu repo and it works, you don't need to set an environment variable.

                    It's the default behaivor of Qt to output to journelctl on linux, https://doc.qt.io/qt-6/qtlogging.html#qDebug

                    qDebug(const char *format, ...)
                    Logs debug message format to the central message handler.
                    

                    I think ubuntu has changed this in a good way.

                    JonBJ 1 Reply Last reply
                    0
                    • jronaldJ jronald

                      @JonB said in qDebug() doesn't show messages in Qt Creator/Application Output:

                      I can only say I always have Qt from Ubuntu repo and it works, you don't need to set an environment variable.

                      It's the default behaivor of Qt to output to journelctl on linux, https://doc.qt.io/qt-6/qtlogging.html#qDebug

                      qDebug(const char *format, ...)
                      Logs debug message format to the central message handler.
                      

                      I think ubuntu has changed this in a good way.

                      JonBJ Offline
                      JonBJ Offline
                      JonB
                      wrote last edited by
                      #15

                      @jronald said in qDebug() doesn't show messages in Qt Creator/Application Output:

                      It's the default behaivor of Qt to output to journelctl on linux, https://doc.qt.io/qt-6/qtlogging.html#qDebug

                      I do not see anything at that link or on that page which mentions journalctl or the systemd journal. I think the "central message handler" in the docs refers to Qt's own QtMessageHandler qInstallMessageHandler(QtMessageHandler handler), which is how qDebug() etc. output their messages. When I Googled for your issue and QT_ASSUME_STDERR_HAS_CONSOLE it came across that this behaviour is specifically in the Arch pre-built. We would come across a lot more questions about this if it applied widely across Linuxes.

                      jronaldJ 1 Reply Last reply
                      0
                      • JonBJ JonB

                        @jronald said in qDebug() doesn't show messages in Qt Creator/Application Output:

                        It's the default behaivor of Qt to output to journelctl on linux, https://doc.qt.io/qt-6/qtlogging.html#qDebug

                        I do not see anything at that link or on that page which mentions journalctl or the systemd journal. I think the "central message handler" in the docs refers to Qt's own QtMessageHandler qInstallMessageHandler(QtMessageHandler handler), which is how qDebug() etc. output their messages. When I Googled for your issue and QT_ASSUME_STDERR_HAS_CONSOLE it came across that this behaviour is specifically in the Arch pre-built. We would come across a lot more questions about this if it applied widely across Linuxes.

                        jronaldJ Offline
                        jronaldJ Offline
                        jronald
                        wrote last edited by
                        #16

                        @JonB said in qDebug() doesn't show messages in Qt Creator/Application Output:

                        this behaviour is specifically in the Arch pre-built

                        But the build script is clean: https://gitlab.archlinux.org/archlinux/packaging/packages/qtcreator/-/blob/main/PKGBUILD?ref_type=heads

                        1 Reply Last reply
                        0
                        • JonBJ Offline
                          JonBJ Offline
                          JonB
                          wrote last edited by JonB
                          #17

                          Then for all I know other non-Arch distros compile with QT_ASSUME_STDERR_HAS_CONSOLE=1. Whatever, if you Google like I did it seems to me this is Arch but not typical Linux distro, that's all I know.

                          FWIW, if you don't wish to recompile Qt itself and you don't wish to have to set environment variable QT_ASSUME_STDERR_HAS_CONSOLE before running to get desired behaviour, be ware you might either:

                          • qputenv("QT_ASSUME_STDERR_HAS_CONSOLE", "1") as the very first statement in main(), before Q[Core]Application creation; or
                          • Use qInstallMessageHandler() to install your own message handler which does write to stderr or similar.
                          1 Reply Last reply
                          2
                          • jronaldJ Offline
                            jronaldJ Offline
                            jronald
                            wrote last edited by
                            #18

                            reported: https://qt-project.atlassian.net/browse/QTCREATORBUG-33823

                            1 Reply Last reply
                            1
                            • aha_1980A Offline
                              aha_1980A Offline
                              aha_1980
                              Lifetime Qt Champion
                              wrote last edited by
                              #19

                              @jronald And to add to @JonB: You can set the environment variables for a Qt Creator Kit in Edit > Preferences > Kits > Kits. It will then be used for all new projects automatically.

                              Regards

                              Qt has to stay free or it will die.

                              1 Reply Last reply
                              0

                              • Login

                              • Login or register to search.
                              • First post
                                Last post
                              0
                              • Categories
                              • Recent
                              • Tags
                              • Popular
                              • Users
                              • Groups
                              • Search
                              • Get Qt Extensions
                              • Unsolved