10

I'm using KDE Plasma under Arch Linux and there are a lot of logs such as

kwin_x11[5129]: qt.qpa.xcb: QXcbConnection: XCB error: 3 (BadWindow), sequence: 11416, resource id: 56623191, major code: 20 (GetProperty), minor code: 0

in my journal.

These errors turned out to be harmless and I'd like to suppress them so that my journal doesn't get flooded. A popular solution I found was to set QT_LOGGING_RULES="*=false" but this disables logging completely even where it's actually useful.

I wonder how I can target only this Qt logging category and leave others untouched?

I've tried e.g. QT_LOGGING_RULES="qt.qpa.xcb.*=false" QT_LOGGING_RULES="qpa.xcb.*=false" QT_LOGGING_RULES="qt.*.xcb.*=false" etc but none of them worked.

Frederick Zhang
  • 789
  • 4
  • 13
  • 28

2 Answers2

7

So far the best I could do:

export QT_LOGGING_RULES='*.debug=false;qt.qpa.*=false'
Frederick Zhang
  • 789
  • 4
  • 13
  • 28
  • Or in your main() try qputenv("QT_LOGGING_RULES","*.debug=false;qt.qpa.*=false"); // supress anoying messages – Harvey Jul 22 '20 at 20:40
  • `qt.core.logging: Ignoring malformed logging rule: ''*.debug=false;qt.qpa.*=false''` I'm getting this on Ubuntu 16.04 and the same `QXcbConnection` error keeps printing. – IsaacS May 08 '21 at 14:46
  • Advice on ArchLinux wiki: https://wiki.archlinux.org/title/Qt#Disable/Change_Qt_journal_logging_behaviour – noraj May 30 '22 at 20:26
-1

As someone has pointed out in the previous answer, for some reason the syntax for specifying multiple rules via QT_LOGGING_RULES involving ; doesn't work on Ubuntu.

What worked for me was using QLoggingCategory::setFilterRules and using \n as separator for the individual rules for this to work. Extending on the previous answer: export QLoggingCategory::setFilterRules(QStringLiteral("*.debug=false\nqt.qpa.*=false"))

  • Sorry, a semicolon as rule delimiter is appropriate. See the [QT Documentation](https://doc.qt.io/qt-6/qloggingcategory.html): *"Logging rules can also be specified in a QT_LOGGING_RULES environment variable; multiple rules can also be separated by semicolons"*. – dodrg Jul 21 '23 at 17:07
  • Corrected the answer. `Qt_LOGGING_RULES` for some reason doesn't work with the `;` on Ubuntu, but it also doesn't work with `\n`. Problem fixed by using `QLoggingCategory`. – machinekoder Jul 23 '23 at 06:25