πŸ›‘️ 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:

  1. Parsed
  2. Correlated
  3. Stored
  4. 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

Popular posts from this blog

Scrutor the built-in Dependency Injection (DI)

πŸ”Œ Extension Methods in C#: Power Up Your Code Without Modifying It

πŸ§… Understanding the Onion Architecture: A Clean Approach to Building Scalable Applications

Understanding Dependency Injection: A Modern Guide for Developers

🌐 CORS in .NET Explained: Solving the Cross-Origin Problem Like a Pro

Ensuring Data Integrity: The Backbone of Reliable Systems

πŸ” JWT (JSON Web Token) Explained: Secure Your APIs the Modern Way

πŸ”— SQL JOINs Explained: Mastering Table Relationships

πŸ—‚️ DROP vs DELETE vs TRUNCATE in SQL: What’s the Difference?