Version

Quick search

Logger object

Differents logging levels are available : trace, debug, info, warning, error and critical.

Examples of usage:

from kivy.logger import Logger

Logger.info('title: This is a info message.')
Logger.debug('title: This is a debug message.')

try:
    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 message easily.

Logger.info('Application: This is a test')

# will appear as

[INFO   ] [Application ] This is a test

Logger configuration

The Logger can be controlled via the Kivy configuration file:

[kivy]
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

print(LoggerHistory.history)
kivy.logger.Logger = <logging.Logger object>[source]

Kivy default logger instance

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

Bases: logging.Handler

Kivy history handler

emit(message)[source]

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.