Quick search

Logger object

The Kivy Logger class provides a singleton logger instance. This instance exposes a standard Python logger object but adds some convenient features.

All the standard logging levels are available : trace, debug, info, warning, error and critical.

Example Usage

Use the Logger as you would a standard Python logger.

from kivy.logger import Logger'title: This is a info message.')
Logger.debug('title: This is a debug message.')

    raise Exception('bleh')
except Exception:
    Logger.exception('Something happened!')

The message passed to the logger is split into two parts separated by a colon (:). The first part is used as a title and the second part is used as the message. This way, you can “categorize” your messages easily.'Application: This is a test')

# will appear as

[INFO   ] [Application ] This is a test

You can change the logging level at any time using the setLevel method.

from kivy.logger import Logger, LOG_LEVELS



Although you are free to use standard python loggers, the Kivy Logger offers some solid benefits and useful features. These include:

  • simplied usage (single instance, simple configuration, works by default)

  • color-coded output

  • output to stdout by default

  • message categorization via colon separation

  • access to log history even if logging is disabled

  • built-in handling of various cross-platform considerations

Kivys’ logger was designed to be used with kivy apps and makes logging from Kivy apps more convenient.

Logger Configuration

The Logger can be controlled via the Kivy configuration file:

log_level = info
log_enable = 1
log_dir = logs
log_name = kivy_%y-%m-%d_%_.txt
log_maxfiles = 100

More information about the allowed values are described in the kivy.config module.

Logger History

Even if the logger is not enabled, you still have access to the last 100 messages:

from kivy.logger import LoggerHistory

kivy.logger.Logger = <Logger kivy (WARNING)>[source]

Kivy default logger instance

class kivy.logger.LoggerHistory(level=0)[source]

Bases: logging.Handler


Do whatever it takes to actually log the specified logging record.

This version is intended to be implemented by subclasses and so raises a NotImplementedError.


Ensure all logging output has been flushed.

This version does nothing and is intended to be implemented by subclasses.