Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I set the log level in glib

Tags:

c

logging

glib

Is there a way to change the log level in glib so e.g. in a release version of an application the debug messages of g_debug won't be logged to the stdout? Do I really need to implement my own log handler for this (g_log_set_handler)?

like image 262
Oliver Sauder Avatar asked Feb 07 '11 20:02

Oliver Sauder


People also ask

How do I increase my log level?

To change log levels as a root user, perform the following: To enable debug logging, run the following command: /subsystem=logging/root-logger=ROOT:change-root-log-level(level=DEBUG) To disable debug logging, run the following command: /subsystem=logging/root-logger=ROOT:change-root-log-level(level=INFO)

What is select log level?

A log level or log severity is a piece of information telling how important a given log message is. It is a simple, yet very powerful way of distinguishing log events from each other. If the log levels are used properly in your application all you need is to look at the severity first.

What is the default log level?

The default level for all loggers is Inherit, and the default level for the root logger is Info. Do not turn on Debug or higher logging without direction from technical support. Turning on this excessive logging for high volume module like system, query, or exec can rapidly flood your system and terminate the servers.


1 Answers

I have asked this question quite a while ago. However things have changed in newer glib version which I just have discovered.

Since glib version 2.32 debug messages are disabled and not shown by default. If you want to turn them on the environment variable G_MESSAGES_DEBUG needs to be set to all.

G_MESSAGES_DEBUG=all /path/to/application

This option might be suitable for you and there is no need for a log handler.

See details http://developer.gnome.org/glib/2.32/glib-running.html

like image 83
Oliver Sauder Avatar answered Oct 18 '22 23:10

Oliver Sauder