1SD_JOURNAL_OPEN(3)              sd_journal_open             SD_JOURNAL_OPEN(3)
2
3
4

NAME

6       sd_journal_open, sd_journal_open_directory, sd_journal_open_files,
7       sd_journal_open_container, sd_journal_close, sd_journal,
8       SD_JOURNAL_LOCAL_ONLY, SD_JOURNAL_RUNTIME_ONLY, SD_JOURNAL_SYSTEM,
9       SD_JOURNAL_CURRENT_USER - Open the system journal for reading
10

SYNOPSIS

12       #include <systemd/sd-journal.h>
13
14       int sd_journal_open(sd_journal **ret, int flags);
15
16       int sd_journal_open_directory(sd_journal **ret, const char *path,
17                                     int flags);
18
19       int sd_journal_open_files(sd_journal **ret, const char **paths,
20                                 int flags);
21
22       int sd_journal_open_container(sd_journal **ret, const char *machine,
23                                     int flags);
24
25       void sd_journal_close(sd_journal *j);
26

DESCRIPTION

28       sd_journal_open() opens the log journal for reading. It will find all
29       journal files automatically and interleave them automatically when
30       reading. As first argument it takes a pointer to a sd_journal pointer,
31       which on success will contain a journal context object. The second
32       argument is a flags field, which may consist of the following flags
33       ORed together: SD_JOURNAL_LOCAL_ONLY makes sure only journal files
34       generated on the local machine will be opened.  SD_JOURNAL_RUNTIME_ONLY
35       makes sure only volatile journal files will be opened, excluding those
36       which are stored on persistent storage.  SD_JOURNAL_SYSTEM will cause
37       journal files of system services and the kernel (in opposition to user
38       session processes) to be opened.  SD_JOURNAL_CURRENT_USER will cause
39       journal files of the current user to be opened. If neither
40       SD_JOURNAL_SYSTEM nor SD_JOURNAL_CURRENT_USER are specified, all
41       journal file types will be opened.
42
43       sd_journal_open_directory() is similar to sd_journal_open() but takes
44       an absolute directory path as argument. All journal files in this
45       directory will be opened and interleaved automatically. This call also
46       takes a flags argument, but it must be passed as 0 as no flags are
47       currently understood for this call.
48
49       sd_journal_open_files() is similar to sd_journal_open() but takes a
50       NULL-terminated list of file paths to open. All files will be opened
51       and interleaved automatically. This call also takes a flags argument,
52       but it must be passed as 0 as no flags are currently understood for
53       this call. Please note that in the case of a live journal, this
54       function is only useful for debugging, because individual journal files
55       can be rotated at any moment, and the opening of specific files is
56       inherently racy.
57
58       sd_journal_open_container() is similar to sd_journal_open() but opens
59       the journal files of a running OS container. The specified machine name
60       refers to a container that is registered with systemd-machined(8).
61
62       sd_journal objects cannot be used in the child after a fork. Functions
63       which take a journal object as an argument (sd_journal_next() and
64       others) will return -ECHILD after a fork.
65
66       sd_journal_close() will close the journal context allocated with
67       sd_journal_open() or sd_journal_open_directory() and free its
68       resources.
69
70       When opening the journal only journal files accessible to the calling
71       user will be opened. If journal files are not accessible to the caller,
72       this will be silently ignored.
73
74       See sd_journal_next(3) for an example of how to iterate through the
75       journal after opening it with sd_journal_open().
76
77       A journal context object returned by sd_journal_open() references a
78       specific journal entry as current entry, similar to a file seek index
79       in a classic file system file, but without absolute positions. It may
80       be altered with sd_journal_next(3) and sd_journal_seek_head(3) and
81       related calls. The current entry position may be exported in cursor
82       strings, as accessible via sd_journal_get_cursor(3). Cursor strings may
83       be used to globally identify a specific journal entry in a stable way
84       and then later to seek to it (or if the specific entry is not available
85       locally, to its closest entry in time) sd_journal_seek_cursor(3).
86
87       Notification of journal changes is available via sd_journal_get_fd()
88       and related calls.
89

RETURN VALUE

91       The sd_journal_open(), sd_journal_open_directory(), and
92       sd_journal_open_files() calls return 0 on success or a negative
93       errno-style error code.  sd_journal_close() returns nothing.
94

NOTES

96       The sd_journal_open(), sd_journal_open_directory() and
97       sd_journal_close() interfaces are available as a shared library, which
98       can be compiled and linked to with the libsystemd pkg-config(1) file.
99

HISTORY

101       sd_journal_open(), sd_journal_close(), SD_JOURNAL_LOCAL_ONLY,
102       SD_JOURNAL_RUNTIME_ONLY, SD_JOURNAL_SYSTEM_ONLY were added in
103       systemd-38.
104
105       sd_journal_open_directory() was added in systemd-187.
106
107       SD_JOURNAL_SYSTEM, SD_JOURNAL_CURRENT_USER, and sd_journal_open_files()
108       were added in systemd-205.  SD_JOURNAL_SYSTEM_ONLY was deprecated.
109

SEE ALSO

111       systemd(1), sd-journal(3), sd_journal_next(3), sd_journal_get_data(3),
112       systemd-machined(8)
113
114
115
116systemd 219                                                 SD_JOURNAL_OPEN(3)
Impressum