codeAPI Reference

Sandbox.Log

calendar_today May 3, 2026 schedule ~1 min read person patrickjr verified 50

Sandbox.Log

Static logging class for console output.

Overview

Log messages appear in the editor console, in-game console (press ~), and log files.

Logging Methods

CSHARP
// Information
Log.Info($"Player joined: {playerName}");

// Warning
Log.Warning("Low ammo!");

// Error
Log.Error("Failed to load save");

Custom Loggers

CSHARP
public static Logger GameLog = new("Game");
public static Logger NetLog = new("Network");

// Usage
GameLog.Info("Game starting");
NetLog.Warning("Connection unstable");
NetLog.Error("Desync detected");

Console Commands

View logs in-game:

CODE
~       // Open console
clear   // Clear console

Log Levels

LevelUse For
InfoGeneral information
WarningPotential issues
ErrorProblems that need attention
VerboseDetailed debugging (filtered)

Performance

Remove debug logs in release:

CSHARP
#if DEBUG
Log.Info($"Debug: {expensiveCalculation}");
#endif

String Interpolation

CSHARP
// Modern C# string interpolation
Log.Info($"Health: {Health}, Position: {WorldPosition}");

// Complex formatting
Log.Info($"Time: {Time.Now:HH:mm:ss}");
Was this helpful?