Class LinuxJournalLogger
Represents the console of a systemd service, whose stdout is the journal: each line starts with its level, as
<3> for an error, which the journal files it under and takes off.
public sealed class LinuxJournalLogger : ILogger
- Inheritance
-
LinuxJournalLogger
- Implements
- Inherited Members
Remarks
The journal stamps each line, so its provider asks TextLogger for no time.
Properties
IsConsole
Gets a value indicating whether stdout is the journal's stream.
public static bool IsConsole { get; }
Property Value
Remarks
systemd names that stream in JOURNAL_STREAM, as device:inode, and a process inherits the variable
with an output of its own — a shell in a terminal a desktop's service started, say — so the stream itself is
compared, as systemd asks: /proc names a socket socket:[inode].
Methods
BeginScope<TState>(TState)
Begins no scope: the journal's lines have none.
public IDisposable? BeginScope<TState>(TState state) where TState : notnull
Parameters
stateTStateThe scope's state.
Returns
Type Parameters
TStateThe type of the scope's state.
GetPriority(LogLevel)
Gets syslog's priority for a level, which the journal files an entry under.
public static int GetPriority(LogLevel logLevel)
Parameters
logLevelLogLevelThe level.
Returns
- int
2 for critical, 3 for error, 4 for warning, 6 for information, and 7 for the rest.
IsEnabled(LogLevel)
Determines whether a level is written: every level is, as its provider filters.
public bool IsEnabled(LogLevel logLevel)
Parameters
logLevelLogLevelThe level.
Returns
Log<TState>(LogLevel, EventId, TState, Exception?, Func<TState, Exception?, string>)
Writes an entry to stdout as a line that starts with its syslog priority.
public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Exception? exception, Func<TState, Exception?, string> formatter)
Parameters
logLevelLogLevelThe entry's level.
eventIdEventIdThe entry's event, which the line leaves out.
stateTStateThe entry's state.
exceptionExceptionThe entry's exception, or null.
formatterFunc<TState, Exception, string>The function that makes the entry's text.
Type Parameters
TStateThe type of the entry's state.