stride3d/stride · error · ArgumentException
Value must be > 0
Error message
Value must be > 0
What it means
LogListener.LogCountFlushLimit is a property guard: the setter rejects any value <= 0 with ArgumentException because the limit controls how many buffered log messages accumulate before a forced flush; zero or negative would make the flush logic meaningless or divide the flush loop into an invalid count.
Solutions
- Set a positive value, e.g. listener.LogCountFlushLimit = 100
- Validate/replace config values <= 0 with a sane default before assigning
- If unbounded buffering is desired, use the listener's flush-timer/API instead of setting the limit to 0
Example fix
// before listener.LogCountFlushLimit = config.FlushLimit; // may be 0 // after listener.LogCountFlushLimit = Math.Max(1, config.FlushLimit);
Defensive patterns
Strategy: validation
Validate before calling
if (limit <= 0) limit = 100; // before: listener.LogCountFlushLimit = limit;
Type guard
bool isValidFlushLimit(int v) => v > 0;
Try / catch
try { listener.LogCountFlushLimit = limit; }
catch (ArgumentException) { listener.LogCountFlushLimit = 100; } Prevention
- Validate config-sourced limits before assignment
- Default to a positive value (e.g. 100)
- Never use 0 to mean 'unlimited' with this property
When it happens
Trigger: Assigning listener.LogCountFlushLimit = 0 (or any negative number) in listener setup code, or computing the limit from config/appsettings where a missing or zero value is passed through unvalidated.
Common situations: Reading the limit from a config file where 0 means 'unlimited' to the developer but the API requires a positive number; initializer syntax new LogListener { LogCountFlushLimit = 0 }; copy-pasted defaults.
Understand the failure class
Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.
Related errors
- [ ] cannot be null in
- Unsupported log message.
- Invalid 'text' argument
- Name cannot be empty
- The provided path is not a valid path name.
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/3e6e4909831a40df.
Report an issue: GitHub.
Appendix: source
Thrown at sources/core/Stride.Core/Diagnostics/LogListener.cs:65
/// <summary>
/// Gets the per-module overrides of <see cref="MinimumLevel"/>, keyed by <see cref="ILogMessage.Module"/>.
/// A listener can stay quiet overall while still following a few modules in detail. Safe to
/// update while the listener is attached.
/// </summary>
public ConcurrentDictionary<string, LogMessageType> ModuleLevels { get; } = new();
/// <summary>
/// Gets or sets the log count flush limit. Default is on every message.
/// </summary>
/// <value>The log count flush limit.</value>
public int LogCountFlushLimit
{
get { return logCountFlushLimit; }
set
{
if (value <= 0)
{
throw new ArgumentException("Value must be > 0");
}
logCountFlushLimit = value;
}
}
/// <summary>
/// Called when a log occurred.
/// </summary>
/// <param name="logMessage">The log message.</param>
protected abstract void OnLog(ILogMessage logMessage);
/// <summary>
/// Returns whether a message passes this listener's filter, and so should reach <see cref="OnLog"/>.
/// The default compares its severity against <see cref="ModuleLevels"/>, falling back to
/// <see cref="MinimumLevel"/>. Override to add conditions of your own.
/// </summary>
/// <param name="logMessage">The log message.</param>View on GitHub (pinned to 96fad776d2)