Class Log
Provides application logging functionality with configurable output, rotation, and compression.
public sealed class Log
- Inheritance
-
Log
- Inherited Members
Constructors
Log()
public Log()
Properties
LogFileName
Gets or sets the log file path. Setting this property closes the current log file and opens a new one.
public static string LogFileName { get; set; }
Property Value
LogLevel
Gets or sets the current logging level. Messages above this level are filtered out.
public static Log.Level LogLevel { get; set; }
Property Value
MaxLogFileDurationSec
Gets or sets the maximum log file duration in seconds before rotation occurs.
public static int MaxLogFileDurationSec { get; set; }
Property Value
MaxLogFileSize
Gets or sets the maximum log file size in bytes before rotation occurs.
public static long MaxLogFileSize { get; set; }
Property Value
RotationHistorySize
Gets or sets the number of rotated log files to keep in history.
public static int RotationHistorySize { get; set; }
Property Value
Methods
Append(Level, string, params object[])
Appends a formatted log message at the specified level.
public static void Append(Log.Level logLevel, string format, params object[] args)
Parameters
logLevelLog.LevelThe severity level of the message.
formatstringThe format string.
argsobject[]The format arguments.
Close()
Closes the current log file and releases resources.
public static void Close()
Debug(Guid, string)
Logs a debug message with an associated object identifier.
public static void Debug(Guid objectId, string message)
Parameters
Debug(string)
Logs a debug message.
public static void Debug(string message)
Parameters
messagestringThe message to log.
DebugFormat(Guid, string, params object[])
Logs a formatted debug message with an associated object identifier.
public static void DebugFormat(Guid objectId, string format, params object[] args)
Parameters
objectIdGuidThe object identifier for correlation.
formatstringThe format string.
argsobject[]The format arguments.
DebugFormat(string, params object[])
Logs a formatted debug message.
public static void DebugFormat(string format, params object[] args)
Parameters
Error(Guid, string)
Logs an error message with an associated object identifier.
public static void Error(Guid objectId, string message)
Parameters
Error(string)
Logs an error message.
public static void Error(string message)
Parameters
messagestringThe message to log.
ErrorFormat(Guid, string, params object[])
Logs a formatted error message with an associated object identifier.
public static void ErrorFormat(Guid objectId, string format, params object[] args)
Parameters
objectIdGuidThe object identifier for correlation.
formatstringThe format string.
argsobject[]The format arguments.
ErrorFormat(string, params object[])
Logs a formatted error message.
public static void ErrorFormat(string format, params object[] args)
Parameters
Flush()
Flushes all unwritten data to disc
public static void Flush()
Info(Guid, string)
Logs an informational message with an associated object identifier.
public static void Info(Guid objectId, string message)
Parameters
Info(string)
Logs an informational message.
public static void Info(string message)
Parameters
messagestringThe message to log.
InfoFormat(Guid, string, params object[])
Logs a formatted informational message with an associated object identifier.
public static void InfoFormat(Guid objectId, string format, params object[] args)
Parameters
objectIdGuidThe object identifier for correlation.
formatstringThe format string.
argsobject[]The format arguments.
InfoFormat(string, params object[])
Logs a formatted informational message.
public static void InfoFormat(string format, params object[] args)
Parameters
Trace(Guid, string)
Logs a trace message with an associated object identifier.
public static void Trace(Guid objectId, string message)
Parameters
Trace(string)
Logs a trace message.
public static void Trace(string message)
Parameters
messagestringThe message to log.
TraceFormat(Guid, string, params object[])
Logs a formatted trace message with an associated object identifier.
public static void TraceFormat(Guid objectId, string format, params object[] args)
Parameters
objectIdGuidThe object identifier for correlation.
formatstringThe format string.
argsobject[]The format arguments.
TraceFormat(string, params object[])
Logs a formatted trace message.
public static void TraceFormat(string format, params object[] args)
Parameters
Warn(Guid, string)
Logs a warning message with an associated object identifier.
public static void Warn(Guid objectId, string message)
Parameters
Warn(string)
Logs a warning message.
public static void Warn(string message)
Parameters
messagestringThe message to log.
WarnFormat(Guid, string, params object[])
Logs a formatted warning message with an associated object identifier.
public static void WarnFormat(Guid objectId, string format, params object[] args)
Parameters
objectIdGuidThe object identifier for correlation.
formatstringThe format string.
argsobject[]The format arguments.
WarnFormat(string, params object[])
Logs a formatted warning message.
public static void WarnFormat(string format, params object[] args)
Parameters
Zip()
Creates a ZIP archive containing the current log file and rotation history.
public static MemoryStream Zip()
Returns
- MemoryStream
A MemoryStream containing the ZIP archive.
Events
Added
Occurs when new log content is written.
public static event Log.AddedEventHandler Added