As mentioned in the introductory section, logging in Slash is done by Logbook. The path to which logs are written is controlled with the -l flag and console verbosity is controlled with -v/-q. Below are some more advanced topics which may be relevant for extending Slash’s behavior.

Controlling Console Colors

Console logs are colorized according to their level by default. This is done using Logbook’s colorizing handler. In some cases you might want logs from specific sources to get colored differently. This is done using slash.log.set_log_color():

>>> import slash.log
>>> import logbook
>>> slash.log.set_log_color('my_logger_name', logbook.NOTICE, 'red')


Available colors are taken from logbook. Options are “black”, “darkred”, “darkgreen”, “brown”, “darkblue”, “purple”, “teal”, “lightgray”, “darkgray”, “red”, “green”, “yellow”, “blue”, “fuchsia”, “turquoise”, “white”


You can also colorize log fiels by setting the log.colorize configuration variable to True

Controlling the Log Subdir Template

The filenames created under the root are controlled with the log.subpath config variable, which can be also a format string receiving the context variable from slash (e.g. sessions/{context.session.id}/{context.test.id}/logfile.log).

Test Ordinals

You can use slash.core.metadata.Metadata.test_index0 to include an ordinal prefix in log directories, for example setting log.subpath to:


The Session Log

Another important config path is log.session_subpath. In this subpath, a special log file will be kept logging all records that get emitted when there’s no active test found. This can happen between tests or on session start/end.

The session log, by default, does not contain logs from tests, as they are redirected to test log files. However, setting the log.unified_session_log to True will cause the session log to contain all logs from all tests.

The Error Log

You can optionally control a separate log file in which only errors and failures are to be logged, through the log.errors_subpath configuration variable.

If set, this variable will hold the subpath (with optional formatting as described above) for a file which will contain only added errors throughout the tests and/or session. This is useful to quickly sift through your runs to only spot the errors, without having to skim through overly verbose debug logs.

Silencing Logs

In certain cases you can silence specific loggers from the logging output. This is done with the log.silence_loggers config path:

slash run -i -o "log.silence_loggers=['a','b']"

Changing Formats

The log.format config path controls the log line format used by slash:

$ slash run -o log.format="[{record.time:%Y%m%d}]- {record.message}" ...