Class ConsoleLogService
- Namespace
- McServerLauncher.Services
- Assembly
- McServerLauncher.dll
Persists every server's console output to a shared, dated log file (%APPDATA%/McServerLauncher/logs/launcher-yyyy-MM-dd.log) so the history survives the app being closed or crashing, not just the in-memory console shown in the UI. A new file starts each day; files older than McServerLauncher.Services.ConsoleLogService.RetentionDays are pruned so the folder doesn't grow forever.
public sealed class ConsoleLogService : IDisposable
- Inheritance
-
ConsoleLogService
- Implements
- Inherited Members
Remarks
Pruning used to happen once, when the app started. The app is made to live in the tray for weeks, so on the machines where the logs pile up most it simply never ran; it now also runs each time the day's file changes.
And a day's file has a ceiling, McServerLauncher.Services.ConsoleLogService.DefaultMaxBytesPerDay. A server stuck printing the same error in a loop used to write until the disk was full. Past the ceiling one line says so and nothing more is written until the next day; the console on screen is not affected.
Fields
Shared
Single shared instance: the log file is one per day for the whole app, not per server.
public static readonly ConsoleLogService Shared
Field Value
Methods
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()
Flush()
Forces buffered lines to disk. Called periodically and on clean shutdown.
public void Flush()
Log(string, string)
Appends one line, timestamped and tagged with the server's name, to today's log file.
public void Log(string serverName, string line)