@model List @{ ViewData["Title"] = "System Logs"; int page = ViewBag.Page; int totalPages = ViewBag.TotalPages; int totalCount = ViewBag.TotalCount; int pageSize = ViewBag.PageSize; string PageLink(int p) => Url.Action("Index", new { search = ViewBag.Search, level = ViewBag.Level, source = ViewBag.Source, from = ViewBag.From, to = ViewBag.To, page = p, pageSize })!; string LevelBadge(string level) => level switch { "Warning" => "bg-warning text-dark", "Error" => "bg-danger", "Fatal" => "bg-dark", "Information" => "bg-info text-dark", _ => "bg-secondary" }; } @section Styles { }

System Logs

@if ((bool)ViewBag.UseAi) { Application Insights— Warning+ events — } else { SQL table — Warning+ events — } @if (totalCount > 0) { @totalCount.ToString("N0") entries } else { No entries yet }
@if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable("WEBSITE_SITE_NAME"))) { Raw Log Files }
@if (ViewBag.TableMissing == true) {
The SystemLogs table hasn't been created yet — it will appear automatically after the first Warning or Error is logged.
} else if (ViewBag.QueryError != null) {
@ViewBag.QueryError
} @* Filters *@
Clear
@if (Model.Count == 0 && ViewBag.TableMissing != true) {
No log entries match your filters.
} else if (Model.Count > 0) { @* Desktop table *@
@foreach (var row in Model) { }
Timestamp Level Source Message User Co.
@row.Timestamp.Tz(ViewBag.CompanyTimeZone as string).ToString("MM/dd HH:mm:ss") @row.Level @(row.SourceContext?.Split('.').LastOrDefault() ?? "—") @row.Message @if (!string.IsNullOrEmpty(row.Exception)) { } @(row.UserName ?? "—") @(row.CompanyId?.ToString() ?? "—")
@* Mobile card view — shown on screens < 992px *@
@foreach (var row in Model) { var cardIconBg = row.Level == "Error" || row.Level == "Fatal" ? "bg-danger" : row.Level == "Warning" ? "bg-warning" : "bg-secondary"; var cardIcon = row.Level == "Error" || row.Level == "Fatal" ? "bi-x-circle" : row.Level == "Warning" ? "bi-exclamation-triangle" : "bi-info-circle"; var msgTruncated = row.Message?.Length > 80 ? row.Message.Substring(0, 80) + "…" : row.Message ?? "—";
@msgTruncated
@row.Timestamp.Tz(ViewBag.CompanyTimeZone as string).ToString("MM/dd HH:mm:ss")
Level @row.Level
Source @(row.SourceContext?.Split('.').LastOrDefault() ?? "—")
@if (row.UserName != null) {
User @row.UserName
} @if (!string.IsNullOrEmpty(row.Exception)) {
Exception Yes
}
}
@* Pagination *@ @if (totalPages > 1) { } }
@* Detail modal *@ @section Scripts { }