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. How do I enable Qt logging for an example?
Forum Updated to NodeBB v4.3 + New Features

How do I enable Qt logging for an example?

Scheduled Pinned Locked Moved Solved General and Desktop
2 Posts 2 Posters 4.8k 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.
  • A Offline
    A Offline
    Asperamanca
    wrote on last edited by Asperamanca
    #1

    I wanted to take a closer look at the widgets/gestures/imagegestures example. For that, I'd like to enable the logging (qCDebug...) contained within the example. I miraculously fail to do so...

    1. I have no idea where to expect output. Application output? General Messages? A file?
    2. According to the description of Q_LOGGING_CATEGORY, "By default, all message types are enabled." Although I do not find any code within the example to disable the created category, I do find any output
    3. A description in main.cpp indicated that I would have to enable logging for the category ("qt.examples.imagegestures.debug=true") for it to work. I tried to create a qtlogging.ini file in my application's start folder. My ini files looks as follows:
    [Rules]
    qt.examples.imagegestures.debug=true
    

    I've seen that there are ways to configure logging categories globally using e.g. an environment variable. But as someone who manages dozens of projects, turning on and off logging categories at a system-global level just doesn't make any sense. I want to configure logging for one application only.

    EDIT: Enabling the logging via QT_LOGGING_RULES env variable works. But as mentioned, having one global point for configuring logging rules is a bit tedious with multiple executables to test.

    aha_1980A 1 Reply Last reply
    0
    • A Asperamanca

      I wanted to take a closer look at the widgets/gestures/imagegestures example. For that, I'd like to enable the logging (qCDebug...) contained within the example. I miraculously fail to do so...

      1. I have no idea where to expect output. Application output? General Messages? A file?
      2. According to the description of Q_LOGGING_CATEGORY, "By default, all message types are enabled." Although I do not find any code within the example to disable the created category, I do find any output
      3. A description in main.cpp indicated that I would have to enable logging for the category ("qt.examples.imagegestures.debug=true") for it to work. I tried to create a qtlogging.ini file in my application's start folder. My ini files looks as follows:
      [Rules]
      qt.examples.imagegestures.debug=true
      

      I've seen that there are ways to configure logging categories globally using e.g. an environment variable. But as someone who manages dozens of projects, turning on and off logging categories at a system-global level just doesn't make any sense. I want to configure logging for one application only.

      EDIT: Enabling the logging via QT_LOGGING_RULES env variable works. But as mentioned, having one global point for configuring logging rules is a bit tedious with multiple executables to test.

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

      Hi @Asperamanca,

      please read https://www.qt.io/blog/2014/03/11/qt-weekly-1-categorized-logging for an introduction.

      I have no idea where to expect output. Application output? General Messages? A file?

      Categorized logging works the same way as the classic QDebug/QWarning/...: By default, it prints to the console

      According to the description of Q_LOGGING_CATEGORY, "By default, all message types are enabled."

      You will need to look into the code to be sure. It may enable only critical categories.

      I tried to create a qtlogging.ini file in my application's start folder.

      No, that one goes to ~/.config/QtProject/qtlogging.ini (so it is global for all apps).

      But as someone who manages dozens of projects, turning on and off logging categories at a system-global level just doesn't make any sense.

      Well you can control everything from your code, so invent whatever mechanism you like :)

      Regards

      Qt has to stay free or it will die.

      1 Reply Last reply
      4

      • Login

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