ByteGuard.SecurityLogger
1.0.0
Prefix Reserved
dotnet add package ByteGuard.SecurityLogger --version 1.0.0
NuGet\Install-Package ByteGuard.SecurityLogger -Version 1.0.0
<PackageReference Include="ByteGuard.SecurityLogger" Version="1.0.0" />
<PackageVersion Include="ByteGuard.SecurityLogger" Version="1.0.0" />
<PackageReference Include="ByteGuard.SecurityLogger" />
paket add ByteGuard.SecurityLogger --version 1.0.0
#r "nuget: ByteGuard.SecurityLogger, 1.0.0"
#:package ByteGuard.SecurityLogger@1.0.0
#addin nuget:?package=ByteGuard.SecurityLogger&version=1.0.0
#tool nuget:?package=ByteGuard.SecurityLogger&version=1.0.0
ByteGuard.SecurityLogger 
ByteGuard.SecurityLogger is a lightweight ILogger wrapper that brings the OWASP Logging Vocabulary to .NET by exposing a set of strongly-typed ILogger methods for common security and audit events.
Instead of ad-hoc log messages like "login ok" or "unauthorized", you log standardized, structured events (e.g. authn_login_success, authz_fail) with consistent property names. This makes your security logs easier to search, alert on, correlate, and reason about, regardless of whether you send logs to Serilog, NLog, Application Insights, Elasticsearch, or something else.
This package is provider-agnostic: it logs through Microsoft.Extensions.Logging so you can keep using your existing logging stack (Serilog, NLog, Application Insights, Seq, etc.) via normal logging providers.
Features
- ✅ OWASP-aligned security event vocabulary
- ✅ Structured logging via
ILoggerscopes/properties - ✅ Works with any
Microsoft.Extensions.ILoggerprovider (NLog, Serilog, etc.)
Getting Started
Installation
This package is published and installed via NuGet.
Reference the package in your project:
dotnet add package ByteGuard.SecurityLogger
Usage
Instantiate a new SecurityLogger instance using either the constructor or the ILogger extensions: AsSecurityLogger().
ILogger logger = /* resolve or create ILogger */
var configuration = new SecurityLoggerConfiguration
{
AppId = "MyApp"
}
// Using constructor
var securityLogger = new SecurityLogger(logger, configuration);
// Using ILogger extensions
var securityLogger = logger.AsSecurityLogger(configuration);
Log your security events:
var user = //...
securityLogger.AuthnLoginSuccess(
"User {UserId} successfully logged in.",
userId: user.Id,
args: user.Id
)
API Design
ByteGuard.SecurityLogger implements the full OWASP Logging Vocabulary: every event type defined by OWASP exists as a corresponding method on SecurityLogger.
One method per event (plus an overload with metadata)
For each OWASP event type, SecurityLogger exposes two overloads:
- A minimal overload for logging the event with just the event label parameters.
securityLogger.Log{event}(
string message,
/* event label arguments (varies by event) */,
params object?[] args
)
- An overload that additionally accepts a
SecurityEventMetadataobject for richer, OWASP-recommended context (client IP, hostname, request URI, etc.).
securityLogger.Log{event}(
string message,
/* event label arguments (varies by event) */,
SecurityEventMetadata metadata,
params object?[] args
)
Parameter order (always the same)
| Parameter | Description |
|---|---|
message |
The human readable log message (typically a message template) |
| Event label arguments | These are the values required to form the OWASP event label, e.g.: authn_login_success:{userId} and authz_fail:{userId,resource} (depending on the even type). These are all nullable and will not be present in the label if provided as null. |
metadata |
Additional structured context recommended by OWASP (source IP, host, request URI, etc.) (Only in the metadata method overload) |
args |
The message template arguments from the 1st parameters |
Example
If an event label requires a userId, the call becomes:
// Providing user ID produces label: authn_login_success:userOne
var userId = "userOne";
securityLogger.LogAuthnLoginSuccess(
"User {UserId} logged in successfully from {Ip}", // Message template
userId, // Label parameters
userId, ip); // Template args
// Without providing user ID produces label: authn_login_success
securityLogger.LogAuthnLoginSuccess(
"User {UserId} logged in successfully from {Ip}", // Message template
null, // Label parameters
userId, ip); // Template args
If you want to add OWASP-style context, use the metadata overload:
securityLogger.LogAuthnLoginSuccess(
"User {UserId} logged in successfully from {Ip}", // Message template
userId, // Label parameters
new SecurityEventMetadata // Event metadata
{
SourceIp = ip,
Hostname = host,
RequestUri = requestUri
},
userId, ip); // Template args
ℹ️ Note: The exact label arguments vary per event type, based on the OWASP Logging Vocabulary definition.
Configuration
The SecurityLogger supports the following configurations:
| Configuration | Required | Default | Description |
|---|---|---|---|
AppId |
Yes | N/A | Application identifier added to the log message, to ensure logs are easy to find for the given application |
DisableSourceIpLogging |
No | true |
Whether to log the SourceIp if provided (logging user IP address may be useful for detection and response, but may be considered personally identifiable information when combined with other data and subject to regulation or deletion requests) |
Supported events
All supported events can be seen in the WIKI
License
ByteGuard.SecurityLogger is Copyright © ByteGuard Contributors - Provided under the MIT license.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.1)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on ByteGuard.SecurityLogger:
| Package | Downloads |
|---|---|
|
ByteGuard.SecurityLogger.AspNetCore
ASP.NET Core-aware logging methods on top of ByteGuard.SecurityLogger |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0 | 126 | 12/26/2025 |
| 1.0.0-dev-01005 | 112 | 12/26/2025 |