mcpField
S
serverpod-logging

serverpod-logging

github.com/serverpodDevelopment3.3k44 installsUpdated 1d ago
Repository

About serverpod-logging

A Serverpod skill for recording request-scoped logs and configuring their storage and output. It helps Serverpod developers inspect logs through the serverpod MCP server or Serverpod Insights.

Key features

  1. 01Request-scoped logging with session.log()
  2. 02Database and console destinations
  3. 03Configurable retention and cleanup
  4. 04Serverpod Insights log inspection

Use cases

  1. 01Record warnings and exceptions during requests
  2. 02Review failed or slow calls in Serverpod Insights

MCP support

Logs can be read through the serverpod MCP server.

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/serverpod/serverpod --skill serverpod-logging

After installing, type/serverpod-loggingin Claude Code to confirm it loaded.

Details

From the project README

Serverpod Logging

Use session.log() during a request. Logs flush when the session closes. Stored in DB and/or printed to console.

Usage

session.log('Operation completed');

session.log('Something went wrong',
  level: LogLevel.warning,
  exception: e,
  stackTrace: stackTrace);

Uncaught endpoint exceptions are logged as session failures in serverpod_session_log.

Destinations

  • Logs are readable through the serverpod MCP server.
  • Database: Tables serverpod_log, serverpod_query_log, serverpod_session_log (when persistent enabled)
  • Console: When console logging enabled (format: text or json)

Defaults: persistent logging is on when a database is configured, and it is only applied on PostgreSQL (SQLite has no persistent session logs). Console logging is on without a database and in the development run mode; the console format is text in development and json in the other run modes.

Configuration

Under sessionLogs: in the config YAML:

SettingDefault
persistentEnabledtrue (with DB)
consoleEnabledtrue (no DB, or development)
consoleLogFormattext (development), json (other modes)
cleanupInterval24h
retentionPeriod90d
retentionCount100000

Each setting also has a SERVERPOD_SESSION_* environment variable, listed in serverpod-configuration/references/environment-variables.md.

Set retention so log tables don't grow unbounded. Avoid logging sensitive data.

Serverpod Insights

Companion app for viewing, searching, and filtering logs and inspecting failed/slow calls. Automatically available when using Serverpod Cloud.

Comments

Markdown supported