Class LogService
Provides the process's log file and applies the user's log settings, for an app or for a VPN service in a process of its own.
public class LogService : IDisposable
- Inheritance
-
LogService
- Implements
- Inherited Members
- Extension Methods
Remarks
The file joins the process's log at the first Start(LogServiceOptions, bool) that opens it; each start, such as a connect's, opens it again, starting afresh unless told to keep what it has, and Stop() closes it. The settings go to VhLogger's level and redaction, which every sink is behind, before the file opens.
Constructors
LogService(string)
Provides the process's log file and applies the user's log settings, for an app or for a VPN service in a process of its own.
public LogService(string logFilePath)
Parameters
logFilePathstringThe log file's path.
Remarks
The file joins the process's log at the first Start(LogServiceOptions, bool) that opens it; each start, such as a connect's, opens it again, starting afresh unless told to keep what it has, and Stop() closes it. The settings go to VhLogger's level and redaction, which every sink is behind, before the file opens.
Properties
Exists
Gets a value indicating whether the log file exists.
public bool Exists { get; }
Property Value
LogFilePath
Gets the log file's path.
public string LogFilePath { get; }
Property Value
Methods
Dispose()
Closes the log file, as Stop() does. Calling it again does nothing.
public void Dispose()
GetLogEventNames(string)
Gets the event names a debug command names.
public static IEnumerable<string> GetLogEventNames(string debugCommand)
Parameters
debugCommandstringThe debug command, whose
/log:parts name events, separated by commas.
Returns
- IEnumerable<string>
The names, each once,
*first.
GetLogEventNames(string[], string)
Joins event names with those a debug command names.
public static IEnumerable<string> GetLogEventNames(string[] currentNames, string debugCommand)
Parameters
currentNamesstring[]The names so far.
debugCommandstringThe debug command, whose
/log:parts name events, separated by commas.
Returns
- IEnumerable<string>
The names, each once,
*among them.
Exceptions
- ArgumentNullException
currentNamesis null.
Start(LogServiceOptions, bool)
Applies the options to the process's log, and opens the log file or closes it. With the options off, it does nothing.
public void Start(LogServiceOptions options, bool deleteOldReport = true)
Parameters
optionsLogServiceOptionsThe options.
deleteOldReportbooltrue to start the file afresh; false to keep what it has, so a log opened before a connect is not the end of the last session's.
Exceptions
- ObjectDisposedException
The service is disposed.
- IOException
The file cannot be opened.
- UnauthorizedAccessException
The process may not write the file.
- ArgumentException
The file's path is not valid.
Stop()
Closes the log file; the log's level and redaction stay. Calling it on a closed file does nothing.
public void Stop()