---
name: "sd-journal"
section: "3"
platform: "linux"
package: "systemd-libs"
version: "262.1-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/sd-journal"
---

# sd-journal(3)

APIs for submitting and querying log entries to and from the journal

## NAME

sd-journal - APIs for submitting and querying log entries to and from the journal

## SYNOPSIS

```
#include <systemd/sd-journal.h>
```

**pkg-config --cflags --libs libsystemd**

## DESCRIPTION

sd-journal.h is part of [**libsystemd**(3)](/libsystemd/3.md) and provides APIs to submit and query log entries. The APIs exposed act both as client for the [**systemd-journald.service**(8)](/systemd-journald.service/8.md) journal service and as parser for the journal files on disk.

See [**sd\_journal\_print**(3)](/sd_journal_print/3.md), [**sd\_journal\_stream\_fd**(3)](/sd_journal_stream_fd/3.md), [**sd\_journal\_open**(3)](/sd_journal_open/3.md), [**sd\_journal\_next**(3)](/sd_journal_next/3.md), [**sd\_journal\_get\_realtime\_usec**(3)](/sd_journal_get_realtime_usec/3.md), [**sd\_journal\_add\_match**(3)](/sd_journal_add_match/3.md), [**sd\_journal\_seek\_head**(3)](/sd_journal_seek_head/3.md), [**sd\_journal\_enumerate\_fields**(3)](/sd_journal_enumerate_fields/3.md), [**sd\_journal\_get\_cursor**(3)](/sd_journal_get_cursor/3.md), [**sd\_journal\_get\_cutoff\_realtime\_usec**(3)](/sd_journal_get_cutoff_realtime_usec/3.md), [**sd\_journal\_get\_cutoff\_monotonic\_usec**(3)](/sd_journal_get_cutoff_monotonic_usec/3.md), [**sd\_journal\_get\_usage**(3)](/sd_journal_get_usage/3.md), [**sd\_journal\_get\_catalog**(3)](/sd_journal_get_catalog/3.md), [**sd\_journal\_get\_fd**(3)](/sd_journal_get_fd/3.md), [**sd\_journal\_has\_runtime\_files**(3)](/sd_journal_has_runtime_files/3.md) and [**sd\_journal\_has\_persistent\_files**(3)](/sd_journal_has_persistent_files/3.md) for more information about the functions implemented.

Command line access for submitting entries to the journal is available with the [**systemd-cat**(1)](/systemd-cat/1.md) tool. Command line access for querying entries from the journal is available with the [**journalctl**(1)](/journalctl/1.md) tool.

## THREAD SAFETY

Functions that operate on sd\_journal objects are thread agnostic — a given sd\_journal pointer may only be used from one thread at a time, but multiple independent threads may use multiple objects concurrently. Some functions — those that are used to send entries to the journal, like [**sd\_journal\_print**(3)](/sd_journal_print/3.md) and similar, or those that are used to retrieve global information like [**sd\_journal\_stream\_fd**(3)](/sd_journal_stream_fd/3.md) and [**sd\_journal\_get\_catalog\_for\_message\_id**(3)](/sd_journal_get_catalog_for_message_id/3.md) — are fully thread-safe and may be called from multiple threads in parallel.

## OPTIONAL DEPENDENCIES

Depending on which build-time options are enabled, functions that operate on sd\_journal objects might cause optional shared libraries to be dynamically loaded via [**dlopen**(3)](/dlopen/3.md), such as decompression libraries (xz, lz4, zstd).

## NOTES

Functions described here are available as a shared library, which can be compiled against and linked to with the **libsystemd** [**pkg-config**(1)](/pkg-config/1.md) file.

The code described here uses [**getenv**(3)](/getenv/3.md), which is declared to be not multi-thread-safe. This means that the code calling the functions described here must not call [**setenv**(3)](/setenv/3.md) from a parallel thread. It is recommended to only do calls to **setenv()** from an early phase of the program when no other threads have been started.

## SEE ALSO

[**systemd**(1)](/systemd/1.md), [**sd\_journal\_print**(3)](/sd_journal_print/3.md), [**sd\_journal\_stream\_fd**(3)](/sd_journal_stream_fd/3.md), [**sd\_journal\_open**(3)](/sd_journal_open/3.md), [**sd\_journal\_next**(3)](/sd_journal_next/3.md), [**sd\_journal\_get\_data**(3)](/sd_journal_get_data/3.md), [**sd\_journal\_get\_realtime\_usec**(3)](/sd_journal_get_realtime_usec/3.md), [**sd\_journal\_add\_match**(3)](/sd_journal_add_match/3.md), [**sd\_journal\_seek\_head**(3)](/sd_journal_seek_head/3.md), [**sd\_journal\_enumerate\_fields**(3)](/sd_journal_enumerate_fields/3.md), [**sd\_journal\_get\_cursor**(3)](/sd_journal_get_cursor/3.md), [**sd\_journal\_get\_cutoff\_realtime\_usec**(3)](/sd_journal_get_cutoff_realtime_usec/3.md), [**sd\_journal\_get\_cutoff\_monotonic\_usec**(3)](/sd_journal_get_cutoff_monotonic_usec/3.md), [**sd\_journal\_get\_usage**(3)](/sd_journal_get_usage/3.md), [**sd\_journal\_get\_fd**(3)](/sd_journal_get_fd/3.md), [**sd\_journal\_query\_unique**(3)](/sd_journal_query_unique/3.md), [**sd\_journal\_get\_catalog**(3)](/sd_journal_get_catalog/3.md), [**sd\_journal\_has\_runtime\_files**(3)](/sd_journal_has_runtime_files/3.md), [**sd\_journal\_has\_persistent\_files**(3)](/sd_journal_has_persistent_files/3.md), [**journalctl**(1)](/journalctl/1.md), [**sd-id128**(3)](/sd-id128/3.md), [**pkg-config**(1)](/pkg-config/1.md)
