Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. logging to different files via qInstallMessageHandler
Qt 6.11 is out! See what's new in the release blog

logging to different files via qInstallMessageHandler

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 3 Posters 1.7k Views
  • 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.
  • sitesvS Offline
    sitesvS Offline
    sitesv
    wrote on last edited by
    #1

    Hi!
    I need to store logs in a different files in one app.
    Is it possible to add some tag to 'log' method?

    I see qInstallMessageHandler has a fixed input parameters.

    JonBJ Christian EhrlicherC 2 Replies Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #6

      Then filter by a keyword in the text. I don't see that your usecase could be handled easier with other logging systems...

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

      1 Reply Last reply
      1
      • sitesvS sitesv

        Hi!
        I need to store logs in a different files in one app.
        Is it possible to add some tag to 'log' method?

        I see qInstallMessageHandler has a fixed input parameters.

        JonBJ Offline
        JonBJ Offline
        JonB
        wrote on last edited by
        #2

        @sitesv
        typedef QtMessageHandler

        void myMessageHandler(QtMsgType, const QMessageLogContext &, const QString &);

        You cannot change/add to those parameters. The message type & context are set for qDebug() and other inbuilt callers, you cannot use those to pass extra information.

        If you are you using your own logging messages see QLoggingCategory Class for creating your own categories and what you can do with them.

        sitesvS 1 Reply Last reply
        0
        • JonBJ JonB

          @sitesv
          typedef QtMessageHandler

          void myMessageHandler(QtMsgType, const QMessageLogContext &, const QString &);

          You cannot change/add to those parameters. The message type & context are set for qDebug() and other inbuilt callers, you cannot use those to pass extra information.

          If you are you using your own logging messages see QLoggingCategory Class for creating your own categories and what you can do with them.

          sitesvS Offline
          sitesvS Offline
          sitesv
          wrote on last edited by
          #3

          @JonB said in logging to different files via qInstallMessageHandler:

          If you are you using your own logging messages see QLoggingCategory Class for creating your own categories and what you can do with them.

          The problem is a storing in the various files, not a creation my own category.

          The target QFile is used in messageHandler only.

          1 Reply Last reply
          0
          • sitesvS sitesv

            Hi!
            I need to store logs in a different files in one app.
            Is it possible to add some tag to 'log' method?

            I see qInstallMessageHandler has a fixed input parameters.

            Christian EhrlicherC Offline
            Christian EhrlicherC Offline
            Christian Ehrlicher
            Lifetime Qt Champion
            wrote on last edited by
            #4

            @sitesv said in logging to different files via qInstallMessageHandler:

            Is it possible to add some tag to 'log' method?

            As @JonB already told you - the category is the tag where you can filter on.

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

            sitesvS 1 Reply Last reply
            1
            • Christian EhrlicherC Christian Ehrlicher

              @sitesv said in logging to different files via qInstallMessageHandler:

              Is it possible to add some tag to 'log' method?

              As @JonB already told you - the category is the tag where you can filter on.

              sitesvS Offline
              sitesvS Offline
              sitesv
              wrote on last edited by sitesv
              #5

              @Christian-Ehrlicher said in logging to different files via qInstallMessageHandler:

              As @JonB already told you - the category is the tag where you can filter on.

              Your advice is to detect which exactly QFile will store a log by log category?

              Very strange advice in my case... This assumes to 10 various log categories for 10 subclasses of MDI app.

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

                Then filter by a keyword in the text. I don't see that your usecase could be handled easier with other logging systems...

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

                1 Reply Last reply
                1
                • sitesvS sitesv has marked this topic as solved on

                • Login

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