Tutorial - User Guide¶
This tutorial shows you how to use Logust with most of its features, step by step.
Each section gradually builds on the previous ones, but it's structured to separate topics, so that you can go directly to any specific one to solve your specific logging needs.
It is also built to work as a future reference, so you can come back and see exactly what you need.
Run the code¶
All the code blocks can be copied and used directly (they are actually tested Python files).
To run any of the examples, copy the code to a file main.py, and run it with Python:
It is HIGHLY encouraged that you write or copy the code, edit it and run it locally.
Changing a format string, a level or a sink and seeing what happens is the fastest way to get a feel for how Logust works. 🤓
Install Logust¶
The first step is to install Logust.
Create a virtual environment, activate it, and then install it:
Logust has no required dependencies. The package ships pre-built wheels for Linux, macOS and Windows, so you don't need a Rust toolchain to install it.
Info
Logust supports Python 3.10 and above.
Optional extras¶
Some integrations need a web framework. You can install it together with Logust using an extra:
These extras install the framework alongside Logust, so logust.contrib.starlette and its RequestLoggerMiddleware work out of the box. You will see them in action in Use with FastAPI.
If you use uv, the same extras work with uv add "logust[fastapi]".
Build from source¶
If you want to hack on Logust itself (for example, to change the Rust core), you can build it from source with maturin:
Note
Source builds need a stable Rust toolchain with cargo. You only need Rust for this: installing from PyPI never compiles anything.
On Windows, activate the environment with .venv\Scripts\activate instead.
Check the installation¶
To check that everything works, log a message straight from the command line:
If you see that line, you are ready to go. 🎉
Advanced User Guide¶
There is also an Advanced User Guide that you can read later after this Tutorial - User Guide.
The Advanced User Guide builds on this one, uses the same concepts, and teaches you some extra features, like custom levels, opt(), background writes and performance tuning.
But you should first read the Tutorial - User Guide (what you are reading right now).
It's designed so that you can set up complete logging for an application with just the Tutorial - User Guide, and then extend it in different ways, depending on your needs, using some of the additional ideas from the Advanced User Guide.