Skip to content

Setting queueLimit causes System.FormatException #142

@object

Description

@object

Which version of Serilog.Sinks.Grafana.Loki are you using?

v8.0.0

Which version of .NET are you using?

net6.0

Describe the bug

I tried to restrict a queue limit using the following code:

ILogger logger = new LoggerConfiguration()
    .WriteTo.GrafanaLoki(uri: "https://...", 
        credentials: new LokiCredentials
        {
            Login = "...",
            Password = "..."
        },
        labels: new List<LokiLabel>
        {
            new() {Key = "app", Value = "loki-memory-test"},
            new() {Key = "environment", Value = "test"}
        },
        queueLimit: 10)
    .MinimumLevel.Debug()
    .CreateLogger();
    SelfLog.Enable(Console.Error);

That causes this error to be logged to console:

Caught exception while emitting to sink Serilog.Sinks.Grafana.Loki.LokiSink: System.FormatException: Input string was not in a correct format.
at System.Text.ValueStringBuilder.ThrowFormatError()
at System.Text.ValueStringBuilder.AppendFormatHelper(IFormatProvider provider, String format, ParamsArray args)
at System.String.FormatHelper(IFormatProvider provider, String format, ParamsArray args)
at Serilog.Debugging.SelfLog.WriteLine(String format, Object arg0, Object arg1, Object arg2)
at Serilog.Core.Sinks.SafeAggregateSink.Emit(LogEvent logEvent)

If I remove the line "queueLimit: 10", then no such error occurs.

To Reproduce

  1. Create a console app
  2. Add Serilog Grafana Loki Nuget package
  3. Create a logger configuration using code specified in the error description
  4. Run the app
  5. Check console output

Expected behavior

Specifying a valid queue limit should not cause System.FormatException

Log/SelfLog output or exception with stacktrace

2022-10-13T14:43:06.3224669Z Caught exception while emitting to sink Serilog.Sinks.Grafana.Loki.LokiSink: System.FormatException: Input string was not in a correct format.
at System.Text.ValueStringBuilder.ThrowFormatError()
at System.Text.ValueStringBuilder.AppendFormatHelper(IFormatProvider provider, String format, ParamsArray args)
at System.String.FormatHelper(IFormatProvider provider, String format, ParamsArray args)
at Serilog.Debugging.SelfLog.WriteLine(String format, Object arg0, Object arg1, Object arg2)
at Serilog.Core.Sinks.SafeAggregateSink.Emit(LogEvent logEvent)

Application or code sample, which could be used to reproduce a bug

No response

Additional context

No response

I have read the documentation

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions