Opened 4 months ago

Closed 3 months 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 -journaldcan 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, -journaldto 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 Douglas R. Reno, 3 months ago

Milestone: 11.111.0

Promote back to 11.0.

comment:2 by pierre, 3 months 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.

Last edited 3 months ago by pierre (previous) (diff)

comment:3 by pierre, 3 months 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:4 by pierre, 3 months ago

But setting either of those variables to 0 or 1 does not work...

comment:5 by pierre, 3 months 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 pierre, 3 months 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 thomas, 3 months 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 pierre, 3 months ago

Owner: changed from blfs-book to pierre
Status: newassigned

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.

comment:9 by pierre, 3 months ago

Resolution: fixed
Status: assignedclosed

Fixed at commit 5fe61b6f3d

Note: See TracTickets for help on using tickets.