Terminology for Logging

Venkatesh-Prasad Ranganath
2 min readMay 19, 2020

Recently, while writing an article about logging in Python, I started identifying artifacts and actions that we commonly use when we talk about logging. Here’s what I came up with.

When we use a logging library, we perform/trigger the following common tasks while using the associated concepts (highlighted in bold).

1. A client issues a log request by executing a logging statement. Often, such logging statements invoke a function/method in the logging (library) API by providing the log data and the logging level as arguments. The logging level specifies the importance of the log request. Log data is often a log message, which is a string, along with some extra data to be logged. Often the logging API is exposed via logger objects.

2. To enable the processing of a request as it threads through the logging library, the logging library creates a log record that represents the log request and captures the corresponding log data.

3. Based on how the logging library is configured (via a logging configuration), the logging library filters log requests/records. This filtering involves comparing the requested logging level to the threshold logging level and passing the log records through user-provided filters.

4. Handlers process the filtered log records to either store the log data (e.g., write the log data into a file) or perform other actions involving the log data (e.g., send an email with the log data). In some logging libraries, before processing log records, a handler may again filter the log records based on the handler’s logging level and user-provided handler-specific filters. Also, when needed, handlers often rely on user-provided formatters to format log records into strings, i.e., log entries.

Independent of the logging library, the above tasks are performed in an order similar to that shown in the figure below.

The flow of tasks when logging via a logging library

The above content is part of an article that is freely available online.

You can purchase a copy of the article as an electronic book from LeanPub and contribute towards helping out with COVID-19 situation.

--

--

Venkatesh-Prasad Ranganath

Engineer / Ex-Academic / Ex-Researcher curious about software and computing.