π‘️ SIEM Logs Explained: How to Build Secure and Auditable .NET Apps
In today’s security-conscious world, it’s no
longer enough to just log errors and crashes. You need to log security-related
events too — for compliance, auditing, and incident
response.
That’s where SIEM logs come in.
π§ What is SIEM?
SIEM (Security Information and Event
Management) is a security
solution that helps organizations collect, store, analyze, and alert
on security-related logs and events.
Popular SIEM platforms include:
- π‘️ Splunk
- π IBM QRadar
- ☁️ Microsoft Sentinel
- π§ Elastic SIEM
- π ArcSight
π¦ What Are SIEM Logs?
SIEM logs are not a specific format. They’re structured
logs that contain security-relevant events, such as:
- User logins / logouts
- Failed login attempts
- Access to sensitive data
- Privilege escalation
- System configuration changes
These logs are sent from apps and servers to a central
SIEM system, where they are:
- Parsed
- Correlated
- Stored
- Alerted upon
π§± Anatomy of a Good SIEM Log
A proper SIEM log should include:
Field |
Example |
Timestamp |
2025-05-26T08:45:12Z |
Event Type |
LoginSuccess, LoginFailure, DataAccess |
User |
jdoe@example.com |
IP Address |
192.168.1.15 |
Application |
MyApp.WebAPI |
Status |
Success or Failure |
Context |
Custom data (e.g., endpoint, entity ID) |
⚙️
How to Send SIEM Logs in .NET
✅ Step 1: Use a Logging Library (Serilog Recommended)
dotnet add package Serilog
dotnet add package Serilog.Sinks.File
You can also use:
- Serilog.Sinks.Syslog (for
direct syslog output)
- Serilog.Sinks.Elasticsearch
(for Elastic SIEM)
✅
Step 2: Configure Logger
csharp
Log.Logger = new LoggerConfiguration()
.Enrich.WithMachineName()
.Enrich.WithThreadId()
.WriteTo.File("logs/security.json", rollingInterval:
RollingInterval.Day)
.CreateLogger();
✅
Step 3: Log Security Events
csharp
Log.Information("User login attempt:
{@LoginInfo}", new {
Timestamp = DateTime.UtcNow,
EventType = "LoginAttempt",
User
= "admin@example.com",
IPAddress = "192.168.0.10",
Status = "Success",
Application = "MyApp.WebAPI"
});
π
You can serialize this as JSON so it can be easily ingested by SIEM tools.
π‘ Sending Logs to a SIEM System
Here are some ways you can forward logs to SIEM
platforms:
Destination |
Method |
Splunk |
HTTP Event Collector (HEC) |
Elastic SIEM |
Send to Elasticsearch |
Syslog server |
Use Serilog + Syslog sink |
Azure Sentinel |
Azure Monitor / Log Analytics agent |
Example (Syslog via Serilog):
csharp
dotnet add package Serilog.Sinks.SyslogMessages
dotnet add package Serilog.Sinks.Network
csharp
CopyEdit
.WriteTo.UdpSyslog("siem-server.example.com",
port: 514)
π§ͺ What Events Should You Log?
Here’s a basic SIEM event checklist:
✅ Login
success / failure
✅ Token generation / refresh
✅ User registration / password changes
✅ Access to protected resources
✅ Permission/role changes
✅ Exceptions related to authentication or security
π Best Practices
- π§± Use structured logging (e.g.,
JSON)
- π Avoid sensitive data (no
passwords, tokens)
- ⏳ Include timestamps in UTC
- π Use consistent naming for event
types
- π§ͺ Test with your SIEM system to
ensure proper ingestion
π Summary
✅ SIEM
logs are structured, security-focused logs
✅ .NET apps can emit these logs using Serilog, NLog, etc.
✅ Logs should contain detailed, structured security events
✅ Logs can be sent via files, HTTP, Syslog, or cloud agents
✅ These logs help with security monitoring, alerting, and audits
Comments
Post a Comment