Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Implementing Thread Safe logging in my Qt Application
Forum Updated to NodeBB v4.3 + New Features

Implementing Thread Safe logging in my Qt Application

Scheduled Pinned Locked Moved Unsolved General and Desktop
14 Posts 5 Posters 2.7k Views 3 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.
  • SGaistS SGaist

    Hi,

    What about Qt's Logging Categories ?
    You can combine that with qInstallMessageHandler to queue all your messages to your dedicated thread.

    A Offline
    A Offline
    Absurd
    wrote on last edited by
    #3

    @SGaist Sorry... I forgot to mention; I am using Qt4. The above is only available since Qt5.2.

    kshegunovK 1 Reply Last reply
    0
    • A Absurd

      @SGaist Sorry... I forgot to mention; I am using Qt4. The above is only available since Qt5.2.

      kshegunovK Offline
      kshegunovK Offline
      kshegunov
      Moderators
      wrote on last edited by
      #4

      @Absurd said in Implementing Thread Safe logging in my Qt Application:

      Sorry... I forgot to mention; I am using Qt4. The above is only available since Qt5.2.

      Any specific reason to use an EOL product version for new development?

      Read and abide by the Qt Code of Conduct

      A 1 Reply Last reply
      0
      • kshegunovK kshegunov

        @Absurd said in Implementing Thread Safe logging in my Qt Application:

        Sorry... I forgot to mention; I am using Qt4. The above is only available since Qt5.2.

        Any specific reason to use an EOL product version for new development?

        A Offline
        A Offline
        Absurd
        wrote on last edited by Absurd
        #5

        @kshegunov Yes; qt4 is installed by default on all of our servers (don't know why, it just how it is), as oppose to qt5 which I'll have to install.
        I want my app to run without any additional installations.

        kshegunovK 1 Reply Last reply
        0
        • Christian EhrlicherC Offline
          Christian EhrlicherC Offline
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on last edited by
          #6

          When I would be your server admin I would not allow you to add a new application with a library which last was updated more than 4 years ago... but if you want to develop with such an old library you have to do such work on your own...
          Otherwise I would have suggested to use log4qt from here

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

          A 1 Reply Last reply
          2
          • A Absurd

            @kshegunov Yes; qt4 is installed by default on all of our servers (don't know why, it just how it is), as oppose to qt5 which I'll have to install.
            I want my app to run without any additional installations.

            kshegunovK Offline
            kshegunovK Offline
            kshegunov
            Moderators
            wrote on last edited by
            #7

            @Absurd said in Implementing Thread Safe logging in my Qt Application:

            I want my app to run without any additional installations.

            You should rethink that, as Qt 4.8.7 was released 3 years ago and is the last patch release of the Qt 4.8 minor release, which itself was released over 8 years ago. You should either upgrade your server(s), or build Qt 5 yourself and use it for new development. Otherwise your approach (in the OP) appears sound.

            Read and abide by the Qt Code of Conduct

            1 Reply Last reply
            0
            • Christian EhrlicherC Christian Ehrlicher

              When I would be your server admin I would not allow you to add a new application with a library which last was updated more than 4 years ago... but if you want to develop with such an old library you have to do such work on your own...
              Otherwise I would have suggested to use log4qt from here

              A Offline
              A Offline
              Absurd
              wrote on last edited by
              #8

              @Christian-Ehrlicher
              We have few more tools that are implemented with qt4 (for historic reasons, I believe).
              What harm could that do? (developing with an old library)

              Thanks, I'll give logqt4 a try...

              1 Reply Last reply
              0
              • Christian EhrlicherC Offline
                Christian EhrlicherC Offline
                Christian Ehrlicher
                Lifetime Qt Champion
                wrote on last edited by
                #9

                Security-wise it's a nightmare to use a library which is not up-to-date.
                And log4qt only works with Qt5(.9)and above

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

                A 1 Reply Last reply
                2
                • Christian EhrlicherC Christian Ehrlicher

                  Security-wise it's a nightmare to use a library which is not up-to-date.
                  And log4qt only works with Qt5(.9)and above

                  A Offline
                  A Offline
                  Absurd
                  wrote on last edited by
                  #10

                  @Christian-Ehrlicher we use these machines for internal debug only (so are our tools)...

                  aha_1980A 1 Reply Last reply
                  0
                  • A Absurd

                    @Christian-Ehrlicher we use these machines for internal debug only (so are our tools)...

                    aha_1980A Offline
                    aha_1980A Offline
                    aha_1980
                    Lifetime Qt Champion
                    wrote on last edited by
                    #11

                    @Absurd as you have to deploy your app to the server anyway, why not deploy Qt 5 together with them?

                    All existing apps stay unchanged, but the new ones start using their own libraries.

                    Qt Creator does it like this, for example.

                    Qt has to stay free or it will die.

                    A 1 Reply Last reply
                    2
                    • aha_1980A aha_1980

                      @Absurd as you have to deploy your app to the server anyway, why not deploy Qt 5 together with them?

                      All existing apps stay unchanged, but the new ones start using their own libraries.

                      Qt Creator does it like this, for example.

                      A Offline
                      A Offline
                      Absurd
                      wrote on last edited by Absurd
                      #12

                      @aha_1980 to be honest, I'd prefer working with qt5, and I also tried to install it on one of our machines before starting the project, but I ran into so many problems and it was so complicated so I gave up.

                      Now it's too late anyway, because I wrote so much code in qt4... (unless qt5 is completely backward compatible with qt4)

                      aha_1980A 1 Reply Last reply
                      0
                      • A Absurd

                        @aha_1980 to be honest, I'd prefer working with qt5, and I also tried to install it on one of our machines before starting the project, but I ran into so many problems and it was so complicated so I gave up.

                        Now it's too late anyway, because I wrote so much code in qt4... (unless qt5 is completely backward compatible with qt4)

                        aha_1980A Offline
                        aha_1980A Offline
                        aha_1980
                        Lifetime Qt Champion
                        wrote on last edited by
                        #13

                        @Absurd

                        Now it's too late anyway, because I wrote so much code in qt4...

                        For sure not ;)

                        (unless qt5 is completely backward compatible with qt4)

                        Not completely, but in many ways. I've a lot of tools compatible with both versions. That needs a few #ifdef, but that's it.

                        I'd recommend doing the upgrade incrementally, because Qt 6 will appear in 2..3 years and Qt 5 will be similar to what Qt 4 is now.

                        Qt has to stay free or it will die.

                        1 Reply Last reply
                        1
                        • A Offline
                          A Offline
                          Absurd
                          wrote on last edited by
                          #14

                          @aha_1980 Thanks. I'll give the qt5 installation one more try.

                          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