Repository navigation
Logging
Алексей . edited this page Mar 21, 2026
·
4 revisions
SF-Arizona uses a two-layer logging system:
- SFLog — low-level background file writer (source)
-
SFLoggerProvider —
ILoggerProviderbridge for modules (source)
All log entries are written to sf_arz.log next to gta_sa.exe via a dedicated background thread, ensuring zero blocking on the game thread.
[2026-03-22 03:23:08.456] [INFO] [chat-violation-monitor] Violation detected player=John
[2026-03-22 03:23:09.789] [FAIL] [rpc-debugger] Parse error: NullReferenceException
[2026-03-22 03:23:10.012] [WARN] [brightbinder] Target player not found
Format: [timestamp] [LEVEL] [module-id] message
[2026-03-22 03:23:08.123] [INFO] RegisterModule id=dialog-scraper type=DialogScraper
[2026-03-22 03:23:08.124] [ERROR] Module faulted id=my-module: System.NullReferenceException...
| LogLevel | Tag |
|---|---|
Trace |
TRCE |
Debug |
DBUG |
Information |
INFO |
Warning |
WARN |
Error |
FAIL |
Critical |
CRIT |
Only Information and above are logged by default.
using Microsoft.Extensions.Logging;
// Available via protected property Log in SFModuleBase:
Log.LogInformation("Module started");
Log.LogWarning("Something unexpected: {Detail}", detail);
Log.LogError(exception, "Failed to process packet");
Log.LogInformation("Player {Name} connected with id={Id}", name, id);Override CreateLogger in your module to use Serilog, NLog, or any ILoggerProvider:
[SFModule("my-module", "MyModule")]
public class MyModule : SFModuleBase
{
protected override ILogger CreateLogger(ModuleContext context)
{
// Example with Serilog:
var serilogLogger = new LoggerConfiguration()
.WriteTo.File("my-module.log")
.CreateLogger();
return new SerilogLoggerFactory(serilogLogger)
.CreateLogger(context.Descriptor.Id);
}
}The default SFLoggerProvider writes to sf_arz.log via the background writer thread.
For infrastructure code outside modules:
SFLog.Info("message");
SFLog.Warn("message");
SFLog.Error("message");
SFLog.Error(exception, "context");
SFLog.WriteFormatted("pre-formatted line"); // raw write
SFLog.Path; // path to sf_arz.log- Главная / Home
- Установка
- Архитектура и совместимость
- SA-MP R1, R3-1, R5-1
- Написание модулей
- Плагины и зависимости
- Жизненный цикл
- API модулей
- Потоки и время жизни
- Ранняя загрузка
- Конфигурация и ассеты