Code · 37 lines · 1648 bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37namespace VanDerHeijden.Logging.Sql;

/// <summary>
/// Represents a single log entry written to a SQL Server table via bulk copy.
/// </summary>
public class SqlLogEntry
{
	/// <summary>Gets or sets the UTC timestamp when the log entry was created.</summary>
	public DateTime Timestamp { get; set; }

	/// <summary>Gets or sets the log level (e.g. <c>"Information"</c>, <c>"Error"</c>).</summary>
	public string Level { get; set; } = string.Empty;

	/// <summary>Gets or sets the logger category name.</summary>
	public string Category { get; set; } = string.Empty;

	/// <summary>Gets or sets the formatted log message.</summary>
	public string Message { get; set; } = string.Empty;

	/// <summary>Gets or sets the string representation of an associated exception, or <see langword="null"/> if none.</summary>
	public string? Exception { get; set; }

	/// <summary>Gets or sets the request path (e.g. <c>"/api/users"</c>), or <see langword="null"/> outside an HTTP context.</summary>
	public string? Path { get; set; }

	/// <summary>Gets or sets the HTTP method (e.g. <c>"GET"</c>), or <see langword="null"/> outside an HTTP context.</summary>
	public string? Method { get; set; }

	/// <summary>Gets or sets the client IP address, or <see langword="null"/> outside an HTTP context.</summary>
	public string? ClientIp { get; set; }

	/// <summary>Gets or sets the Referer header value, or <see langword="null"/> outside an HTTP context.</summary>
	public string? Referer { get; set; }

	/// <summary>Gets or sets the User-Agent header value, or <see langword="null"/> outside an HTTP context.</summary>
	public string? UserAgent { get; set; }
}