简体   繁体   中英

How to adjust the log output level of GTK4?

When developing an application based on GTK4, a log will be printed every time it is started. How can I get rid of it?

(conquerdocker:17460): Gtk-WARNING **: 09:13:21.962: Unknown key gtk-button-images in /home/aszswaz/.config/gtk-4.0/settings.ini

(conquerdocker:17460): Gtk-WARNING **: 09:13:21.962: Unknown key gtk-menu-images in /home/aszswaz/.config/gtk-4.0/settings.ini

(conquerdocker:17460): Gtk-WARNING **: 09:13:21.963: Unknown key gtk-toolbar-style in /home/aszswaz/.config/gtk-4.0/settings.ini

If you are not concerned about having any log output when you are executing your program, you could call your program and redirect the logging output to "/dev/null", such as:

./your_program_name > /dev/null

Alternatively, since your program is most likely a GUI program and doesn't require a terminal/console window, you could set up a desktop file similar to the following example.

[Desktop Entry]
Type=Application
Name=GtkProgramName
Icon=/home/username/.local/share/icons/hicolor/48x48/apps/GTK.png
Categories=Utilities;
StartupNotify=true
Terminal=false
Exec=/path/to/your/Programs/your_program_name

The key attribute here is the "Terminal=false" attribute which will run your program without a terminal, and therefore a user would not see spurious messages. Desktop files usually are placed in the "~/.local/share/applications folder" and have a permission mask of "rw-rw-r--".

You might give those options a try.

Regards.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM