<PackageReference Include="System.Diagnostics.EventLog" Version="9.0.2" />

EventLogMode

public enum EventLogMode
Determines the behavior for the event log service handles an event log when the log reaches its maximum allowed size (when the event log is full).

Archive the log when full, do not overwrite events. The log is automatically archived when necessary. No events are overwritten.

New events continue to be stored when the log file is full. Each new incoming event replaces the oldest event in the log.

Retain = 2

Do not overwrite events. Clear the log manually rather than automatically.