diff --git a/src/BCards.Web/Controllers/HealthController.cs b/src/BCards.Web/Controllers/HealthController.cs index f1805a7..137d17b 100644 --- a/src/BCards.Web/Controllers/HealthController.cs +++ b/src/BCards.Web/Controllers/HealthController.cs @@ -164,6 +164,18 @@ public class HealthController : ControllerBase _logger.LogInformation("Uptime Kuma health check: {Status} in {Duration}ms", response.status, stopwatch.ElapsedMilliseconds); + + var memoryMB = Math.Round(GC.GetTotalMemory(false) / 1024.0 / 1024.0, 2); + var uptimeMinutes = (DateTime.UtcNow - Process.GetCurrentProcess().StartTime).TotalMinutes; + + _logger.LogInformation("[HEALTH] Memory: {memoryBytes} MemoryMB: {memoryMB} ThreadPool: {threadPool} ProcessId: {processId} ActiveConnections: {activeConnections} UptimeMinutes: {uptimeMinutes}", + GC.GetTotalMemory(false), + memoryMB, + ThreadPool.ThreadCount, + Process.GetCurrentProcess().Id, + HttpContext.Connection?.Id ?? "null", + Math.Round(uptimeMinutes, 1)); + return Ok(response); } catch (Exception ex) @@ -229,7 +241,22 @@ public class HealthController : ControllerBase } var entry = healthReport.Entries.First().Value; - + + _logger.LogInformation("[HEALTH_CHECK] Service: {serviceName} Status: {status} Duration: {duration} ResponseTime: {responseTime} Timestamp: {timestamp} Data: {data}", + serviceName, + entry.Status.ToString().ToLower(), + entry.Duration.TotalMilliseconds, + stopwatch.ElapsedMilliseconds, + DateTime.UtcNow, + entry.Data != null ? string.Join(", ", entry.Data.Select(d => $"{d.Key}:{d.Value}")) : "none"); + + if (entry.Exception != null) + { + _logger.LogError("[HEALTH_CHECK] Service: {serviceName} Status: {status} Duration: {duration} Error: {error} Exception: {exception}", + serviceName, entry.Status.ToString().ToLower(), stopwatch.ElapsedMilliseconds, + entry.Exception.Message, entry.Exception.ToString()); + } + var response = new { service = serviceName,