Results 1 to 6 of 6

Thread: QLoggingCategory question

  1. #1
    Join Date
    Oct 2016
    Posts
    7
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default QLoggingCategory question

    I wrote a simple program to understand QLoggingCategory class.

    I found with the following 2 statements.
    QLoggingCategory category("qtCustom.log");
    qCDebug(category) << "main a debug message";
    The QT Application output pane shows:
    qtCustom.log main a debug message

    But when I change them to :
    QLoggingCategory category("qt.Custom.log");
    qCDebug(category) << "main a debug message";
    then QT Application output pane shows nothing.

    Does anybody know the reason?

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: QLoggingCategory question

    Have you changed/added the corresponding Q_DECLARE_LOGGING_CATEGORY() and Q_LOGGING_CATEGORY() macros?
    Have you ensured the category is enabled?

  3. #3
    Join Date
    Oct 2016
    Posts
    7
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QLoggingCategory question

    I only changed the string parameter, qt.custom.log, and qtcustom.log

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QLoggingCategory question

    There could be a logging configuration that disables "qt.*" or "qt.*.log", etc.

    This would match the second string, but not the first.

    Cheers,
    _

  5. #5
    Join Date
    Oct 2016
    Posts
    7
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QLoggingCategory question

    the whole code block is :

    int main(int argc, char *argv[])
    {
    QApplication a(argc, argv);
    QLoggingCategory::setFilterRules(QStringLiteral("q t.custom.log.debug=false"));
    qSetMessagePattern("%{category} %{message}");

    Widget w;
    QLoggingCategory category("qtCustom.log");
    qCDebug(category) << "main a debug message";
    w.show();

    return a.exec();
    }

    And I tried to change false to "true", "debug" to "release", "qtCustom.log.debug=false" etc.
    but still got same result.

    #include "widget.h"
    #include "ui_widget.h"

    Q_LOGGING_CATEGORY(QT_CUSTOM_LOG, "qt.custom.log")

    Widget::Widget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::Widget)
    {
    ui->setupUi(this);
    QLoggingCategory custom("construct");
    qCDebug(custom) << "Widget initialzation ...";
    }

    Widget::~Widget()
    {
    delete ui;
    }

  6. #6
    Join Date
    Oct 2016
    Posts
    7
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QLoggingCategory question

    I got it, QLoggingCategory::setFilterRules(QStringLiteral("q t.custom.log.debug=false")); should be changed to
    QLoggingCategory::setFilterRules(QStringLiteral("q t.custom.log.debug=true"));

Similar Threads

  1. question about xmpp (different question)
    By davinciomar in forum Newbie
    Replies: 9
    Last Post: 6th September 2016, 13:52
  2. How to define string of QLoggingCategory during runtime?
    By antimatter in forum Qt Programming
    Replies: 1
    Last Post: 31st May 2016, 14:23
  3. Using QLoggingCategory, rules precedence seem backwards
    By don@thegagnes.com in forum Qt Programming
    Replies: 3
    Last Post: 5th December 2014, 18:17
  4. Qwt question
    By baray98 in forum Qwt
    Replies: 3
    Last Post: 26th November 2007, 20:31

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.