Opened 4 years ago
Closed 4 years ago
#15437 closed enhancement (fixed)
Add -syslog/-journald to QT
Reported by: | thomas | Owned by: | pierre |
---|---|---|---|
Priority: | normal | Milestone: | 11.0 |
Component: | BOOK | Version: | git |
Severity: | trivial | Keywords: | |
Cc: |
Description ¶
Summary of configuration of QT shows currently
Logging backends: journald ............... no syslog ............... no
which means that none of the available logging backends are used. To switch them on, -syslog
or -journald
can be used - its recommended to not use both at the same time as it is undefined which one will be used at runtime.
For example, using syslog
, the summary output changes to
Logging backends: journald ............... no syslog ............... yes
So, suggestion is to add -syslog
to the SysV variant of the book, -journald
to the systemd variant.
A nice article about logging and the two switches is at https://www.ics.com/blog/whats-new-qt-560-logging-syslog-and-journald
Change History (9)
comment:1 by , 4 years ago
Milestone: | 11.1 → 11.0 |
---|
comment:2 by , 4 years ago
I'm having some problem with this. After building with -syslog:
syslog ............................... yes
It seems the behavior of the test programs is not the same as the ones in the link above. QT_LOGGING_TO_CONSOLE=0 seems to have no effect.
comment:3 by , 4 years ago
Actually, I see in qt-everywhere-src-5.15.2/qtbase/dist/changes-5.11.0:
The QT_LOGGING_TO_CONSOLE environment variable has been deprecated. Use the more specific QT_ASSUME_STDERR_HAS_CONSOLE or QT_FORCE_STDERR_LOGGING, depending on your usecase
comment:5 by , 4 years ago
For the record, here is the command for compiling the test programs (qt5ess.cpp):
g++ -I /opt/qt5/include -I /opt/qt5/include/QtCore -L /opt/qt5/lib -lQt5Core -o qt5ess -fPIC qt5ess.cpp
Forgot to say that the example2 program runs as advertised (but syslog is done by the custom handler, not by Qt)
comment:6 by , 4 years ago
Looking at the logic in qtbase/src/corelib/global/qlogging.cpp, it seems there is no way to prevent logging to console if running from a tty (if /dev/tty can be opened). All default message handlers call shouldLogToStderr, which tests if QT_FORCE_STDERR_LOGGING is set (in which case logging goes to stderr), and then call stderrHasConsoleAttached if not. This function first tests QT_LOGGING_TO_CONSOLE. If it is set, log goes to stderr, and a warning about deprecation is issued. If it is not set, then it tests QT_ASSUME_STDERR_HAS_CONSOLE, and logs to stderr if it is set. If none of those variables is set, it tests if /dev/tty can be open, and logs to stderr if it can.
comment:7 by , 4 years ago
Tests went fine when program is started without a console (start with a DM). The messages appear in syslog (assuming that they do also in journal under systemd).
comment:8 by , 4 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
Looks like I am unable to get it to go to syslog under gnome/sysv...
Let's add this to the book, since it works for Thomas.
Promote back to 11.0.