Skip to content

Logging & Log Rotation

Christophe-Rogiers edited this page Oct 4, 2026 · 64 revisions

Table of Contents

  1. Introduction
  2. Logs in Servy Manager
  3. Event IDs
  4. Logging Settings
  5. CLI Options
  6. CLI Example
  7. PowerShell Options
  8. PowerShell Example
  9. Internal Servy Logs

Introduction

Servy provides flexible logging to monitor your services in real time, capturing important events in Windows Event Logs, local log files at %ProgramData%\Servy\logs\ as well as standard output and error streams (stdout/stderr). Logs can be viewed in Servy Manager, filtered by level, date, or keyword, and optionally rotated to prevent disk space issues.

Logs in Servy Manager

servy-manager-logs
  • Important events are logged in Windows Event Viewer and can be browsed from Servy Manager.
  • Logs Tab: Quickly search logs by log level, date, and keyword for easy monitoring and troubleshooting.
  • Message Format: Each log entry starts with [ServiceName] followed by the message.
    • Example: [MyService] Health monitoring started.

Event IDs

Servy assigns specific Event IDs to distinguish between types of service logs. These IDs are recorded in Windows Event Viewer and are useful for filtering, searching, and automation.

Level Event ID Range Purpose
Info 1000-1099 Lifecycle milestones (start, stop, recovery success)
Warning 2000-2099 Recoverable degradations (retries, fallback paths)
Error 3000-3099 Core errors (DPAPI failures, DB init failures, ...)
Error 3100-3199 Script / scheduled-task errors (ServyFailureEmail.ps1 etc.)
  • 2002 = transient migration warning (pre-escalation; auto-clears on next successful read)
  • 3001 = key unprotect failed
  • 3003 = persistent migration failure
  • 3103 = scheduled-task script error
  • 3104 = scheduled-task script dependency error

Note

Event IDs are per event type, not unique per entry.

Logging Settings

The "Logging" tab in the desktop app lets you configure stdout and stderr logging, including size-based log rotation, date-based log rotation, the maximum number of rotated log files to retain, and additional options such as enabling debug logs.

servy-config-logging

Note

If both size-based and date-based rotation are enabled, size-based rotation takes precedence.

Note

Enabling the debug option will record sensitive information in the local log file at %ProgramData%\Servy\logs\services\<ServiceName>\Servy.Service.log. This behavior only occurs when local logging is enabled, which is the default setting. Sensitive data is never recorded in the Windows Event Log. The CLI show command and Show-ServyService mask the encrypted fields by default; --decrypt / -Decrypt prints the parameters and environment variables in clear text (the stored password always stays masked). See Servy CLI and Servy PowerShell Module.

Note

Enabling Console UI (--enableConsoleUI) disables stdout/stderr redirection at the OS level - the child process keeps an attached console handle instead of pipes. Servy cannot capture or rotate the output in that mode, so the configured --stdout / --stderr paths will remain empty. Use one or the other, not both.

CLI Options

  • --stdout - stdout log path
  • --stderr - stderr log path
  • --enableSizeRotation
  • --rotationSize - size in MB (1-10240)
  • --enableDateRotation
  • --dateRotationType - Daily, Weekly, Monthly, None (None disables date-based rotation; use when only size rotation is desired)
  • --useLocalTimeForRotation - use local time instead of UTC (default: false)
  • --maxRotations - number of files, 0 = unlimited (maximum 10000)
  • --debug - Enable debug logs. Records environment variables and process parameters in %ProgramData%\Servy\logs\services\<ServiceName>\Servy.Service.log. Not recommended for production.

CLI Example

servy-cli install `
  --name="My NodeJS Service" `
  --description="My NodeJS Server" `
  --path="C:\Program Files\nodejs\node.exe" `
  --startupDir="C:\Apps\App" `
  --params="C:\Apps\App\index.js" `
  --startupType="Automatic" `
  --priority="Normal" `
  --stdout="C:\Apps\App\stdout.log" `
  --stderr="C:\Apps\App\stderr.log" `
  --enableSizeRotation `
  --rotationSize="10" `
  --maxRotations="5" `
  --debug

PowerShell Options

  • -Stdout (string)
  • -Stderr (string)
  • -EnableSizeRotation (switch)
  • -RotationSize (int)
  • -EnableDateRotation (switch)
  • -DateRotationType (Daily, Weekly, Monthly, None - None disables date-based rotation; use when only size rotation is desired)
  • -UseLocalTimeForRotation (switch)
  • -MaxRotations (int, 0 = unlimited)
  • -EnableDebugLogs - Enable debug logs. Records environment variables and process parameters in %ProgramData%\Servy\logs\services\<ServiceName>\Servy.Service.log. Not recommended for production.

PowerShell Example

Import-Module "C:\Program Files\Servy\Servy.psm1" -Force

$installParams = @{
    Quiet              = $true
    Name               = "My NodeJS Service"
    Description        = "My NodeJS Server"
    Path               = "C:\Program Files\nodejs\node.exe"
    StartupDir         = "C:\Apps\App"
    Params             = "C:\Apps\App\index.js"
    StartupType        = "Automatic"
    Priority           = "Normal"

    Stdout             = "C:\Apps\App\stdout.log"
    Stderr             = "C:\Apps\App\stderr.log"
    EnableSizeRotation = $true
    RotationSize       = 10
    MaxRotations       = 5
    EnableDebugLogs    = $true
}

Install-ServyService @installParams

Internal Servy Logs

Servy's own log files are under %ProgramData%\Servy\logs\:

  • logs\ - the logs of the Desktop App, Servy Manager, servy-cli and the Servy host service (Servy.Host.log). Only SYSTEM and Administrators can read them.
  • logs\services\<ServiceName>\ (v10.2+) - one folder per service, holding Servy.Service.log (the service wrapper) and Servy.Restarter.log. Only that service's account, SYSTEM and Administrators can reach it. A service name that holds a character a folder name cannot hold is percent-encoded (My:Service logs to logs\services\My%3AService\); see Security for the full rules.

Before v10.2, every service wrote to a single shared logs\Servy.Service.log. An upgrade leaves that file where it is, untouched; no service writes to it any more, and it can be deleted once it is no longer needed.

See Advanced Configuration.

Tip

Combine log rotation with health monitoring and pre-launch scripts to avoid disk space issues.

Clone this wiki locally