---
title: Use Synchronized Time (UTC) In Logs
impact: MEDIUM
impactDescription: enables accurate incident correlation
tags: logging, time, utc, synchronization, security, csharp
---

## Use Synchronized Time (UTC) In Logs

Always use UTC time for logs and database records.

**Incorrect (local time):**

```csharp
_logger.LogInformation("Action at {Time}", DateTime.Now); // Depends on server timezone
```

**Correct (UTC):**

```csharp
_logger.LogInformation("Action at {Time}", DateTime.UtcNow); 

// Configure Serilog to output UTC
// .WriteTo.Console(outputTemplate: "{Timestamp:u} ...")
```

**Tools:** Roslyn Analyzers, SonarQube
