Skip to content

Serilog

reference
1 min readUpdated

Kind: Service

Source: Pams/API/Pams.API/Pams.API.csproj (line 1)

Part of: Pams

NuGet package dependency

Serilog is a NuGet package dependency in Pams.API for writing structured application logs. It records request handling, operational events, and failures so API behavior can be inspected through configured logging outputs.

Diagram

mermaid
sequenceDiagram
    participant Client
    participant API as Pams.API
    participant Serilog
    participant Sink as Log Sink

    Client->>API: Send API request
    API->>Serilog: Write structured log event
    Serilog->>Sink: Emit formatted log entry
    API-->>Client: Return API response

Usage

ts
const response = await fetch("/api/pams/records", {
  method: "GET",
  headers: {
    Accept: "application/json",
  },
});

if (!response.ok) {
  throw new Error(`API request failed: ${response.status}`);
}

const records = await response.json();
console.log("Received Pams API response", { records });

Server-side handling of this request can write a structured Serilog event with request details, response status, and error information.

AI Coding Instructions

  • Keep Serilog configuration in the API startup and dependency-registration path rather than creating logger instances inside request handlers.
  • Write structured log properties instead of interpolating values into message text.
  • Include request context, identifiers, and exception details when logging API failures.
  • Avoid logging credentials, tokens, personal data, or other sensitive request values.
  • Check the project package references and existing sink configuration before adding Serilog packages or changing log output behavior.

Used by

1 reference from 1 file. Each is a place in this repository where the symbol is actually used — go read one rather than trusting an example.

Injected or called by (1)

  • Pams.APIPams/API/Pams.API/Pams.API.csproj:1

Was this page helpful?

Download as PDF