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 i can disable qDebug() and console.log() logs in final release ?
Forum Updated to NodeBB v4.3 + New Features

How i can disable qDebug() and console.log() logs in final release ?

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 3 Posters 4.9k 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.
  • D Offline
    D Offline
    divaindie
    wrote on 25 Feb 2019, 15:42 last edited by aha_1980
    #1

    i want to disable all logs in c++ and qml in application which iam going to release.

    //for example in c++ for debug purpose i have added something like this.
    qDebug() << "clicked!!";
    
    //and in qml
    console.log("hello from app")
    

    how i can disable these logs in final release without affecting the existing code?.
    also i want to enable these whenever i want to debug .is this even possible ? .please let me know.
    thanks.

    G 1 Reply Last reply 25 Feb 2019, 15:44
    0
    • D divaindie
      25 Feb 2019, 15:42

      i want to disable all logs in c++ and qml in application which iam going to release.

      //for example in c++ for debug purpose i have added something like this.
      qDebug() << "clicked!!";
      
      //and in qml
      console.log("hello from app")
      

      how i can disable these logs in final release without affecting the existing code?.
      also i want to enable these whenever i want to debug .is this even possible ? .please let me know.
      thanks.

      G Offline
      G Offline
      Gojir4
      wrote on 25 Feb 2019, 15:44 last edited by
      #2

      Hi @divaindie,

      By putting this in your pro file (I'm not sure it works with qml console message, but I guess it is):

      #No debug output in release mode
      CONFIG(release, debug|release):DEFINES += QT_NO_DEBUG_OUTPUT
      
      1 Reply Last reply
      4
      • D Offline
        D Offline
        divaindie
        wrote on 25 Feb 2019, 15:57 last edited by
        #3

        this works only for c++ not for QML .is there any similar way i can disable logs qml also by adding few lines in .pro file?

        K 1 Reply Last reply 25 Feb 2019, 16:23
        0
        • D divaindie
          25 Feb 2019, 15:57

          this works only for c++ not for QML .is there any similar way i can disable logs qml also by adding few lines in .pro file?

          K Offline
          K Offline
          KroMignon
          wrote on 25 Feb 2019, 16:23 last edited by
          #4

          @divaindie You can set environment variable QT_LOGGING_RULES=qml=false

          For example by add in your main.cpp

          #ifdef QT_NO_DEBUG_OUTPUT
             qputenv("QT_LOGGING_RULES", "qml=false");
          #endif
          

          Regards
          Fabrice

          It is an old maxim of mine that when you have excluded the impossible, whatever remains, however improbable, must be the truth. (Sherlock Holmes)

          1 Reply Last reply
          7
          • D Offline
            D Offline
            divaindie
            wrote on 25 Feb 2019, 16:53 last edited by
            #5

            @KroMignon said in How i can disable qDebug() and consloe.log() logs in final release ?:

            #ifdef QT_NO_DEBUG_OUTPUT
            qputenv("QT_LOGGING_RULES", "qml=false");
            #endif

            thanks !!! it is working !!!

            1 Reply Last reply
            1

            1/5

            25 Feb 2019, 15:42

            • Login

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