Local Sinks
UnityLogSink
Writes to UnityEngine.Debug.Log, Debug.LogWarning, and Debug.LogError depending on the log level. Applies rich-text coloring in the Editor (gray for Debug, white for Info, yellow for Warning, red for Error/Assert).
Added automatically by LogixInitializer. You rarely need to add it manually.
// Already added - no setup needed
// But you can add it yourself if you disable auto-init:
Log.Container.AddSink(new UnityLogSink());
Supports a custom formatter via the Formatter property:
var unitySink = new UnityLogSink();
unitySink.Formatter = new JsonFormatter();
Supports a minimum level filter. Messages below MinLevel are dropped:
var unitySink = new UnityLogSink { MinLevel = LogLevel.Warning };
// Only Warning, Error, and Assert messages will reach Debug.Log*
FileLogSink
Writes to a text file. Automatically rotates when the file exceeds maxSizeBytes:
Log.Container.AddSink(new FileLogSink("Logs/Game.log", 50L * 1024 * 1024));
- Creates parent directories automatically
- Thread-safe via
lock - Rotation renames the current file to
path.yyyyMMddHHmmssfff - Supports a custom formatter via the
Formatterproperty - Supports a minimum level filter via the
MinLevelproperty - Buffered writes — messages are written immediately to the stream but flushed to disk asynchronously every 500ms. This avoids per-message disk I/O overhead. A final flush always runs on
Dispose(), so no data is lost on graceful shutdown.
var fileSink = new FileLogSink("Logs/Game.log");
fileSink.Formatter = new JsonFormatter();
fileSink.MinLevel = LogLevel.Info; // skip Debug noise
Enable file logging via config:
Log.WithOptions(o => o.EnableFileLogging = true);
// Uses o.LogFilePath and o.MaxLogFileSize
ConsoleLogSink
Writes to System.Console with level-based foreground colors (White/White/Yellow/Red/Magenta). Ideal for headless or dedicated server builds.
Log.Container.AddSink(new ConsoleLogSink());
Supports a custom formatter via the Formatter property and a minimum level via MinLevel:
var consoleSink = new ConsoleLogSink();
consoleSink.Formatter = new JsonFormatter();
consoleSink.MinLevel = LogLevel.Warning;