diff --git a/Serilog.Logfmt/Directory.Build.props b/Serilog.Logfmt/Directory.Build.props
index 6749c23..c8bf63a 100644
--- a/Serilog.Logfmt/Directory.Build.props
+++ b/Serilog.Logfmt/Directory.Build.props
@@ -4,17 +4,17 @@
https://github.com/eiximenis/Serilog.Logfmt/
https://github.com/eiximenis/Serilog.Logfmt
Serilog.Logfmt
- 1.0.3$(VersionSuffix)
+ 1.0.4$(VersionSuffix)
Eiximenis
Lo CrestiÃ
true
true
true
- snupkg
+ snupkg
true
-
\ No newline at end of file
+
diff --git a/Serilog.Logfmt/LogfmtFormatter.cs b/Serilog.Logfmt/LogfmtFormatter.cs
index 0932a4c..6224eab 100644
--- a/Serilog.Logfmt/LogfmtFormatter.cs
+++ b/Serilog.Logfmt/LogfmtFormatter.cs
@@ -50,7 +50,7 @@ public void Format(LogEvent logEvent, TextWriter output)
msg = sw.ToLogfmtQuotedString(_options.DoubleQuotesAction);
}
- if (msg.Contains(" "))
+ if (msg.Contains(" ") || msg.Contains("="))
{
output.WriteLine($@"""{msg}""");
}
@@ -58,7 +58,7 @@ public void Format(LogEvent logEvent, TextWriter output)
{
output.WriteLine(msg);
}
-
+
if (logEvent.Exception != null)
{
LogException(logEvent, output);
@@ -73,7 +73,7 @@ private void LogException(LogEvent logEvent, TextWriter output)
output.Write("ts={0} ", logEvent.Timestamp.UtcDateTime.ToString("o"));
if (dataOptions != LogfmtExceptionDataFormat.None)
{
-
+
if (dataOptions.HasFlag(LogfmtExceptionDataFormat.Level))
{
output.Write("level={0} ", _options.GrafanaLevels ? "err" : LogEventLevel.Error.ToString());
@@ -112,7 +112,7 @@ private string GrafanaLevelValue(LogEventLevel level)
case LogEventLevel.Verbose: return "trace";
default: return "unknown";
}
- }
+ }
private string GetNormalizedKeyCase(string key)
{
diff --git a/Serilog.Logfmt/LogfmtValueFormatter.cs b/Serilog.Logfmt/LogfmtValueFormatter.cs
index b1bb532..10027ad 100644
--- a/Serilog.Logfmt/LogfmtValueFormatter.cs
+++ b/Serilog.Logfmt/LogfmtValueFormatter.cs
@@ -45,7 +45,7 @@ protected override bool VisitScalarValue(TextWriter state, ScalarValue scalar)
var keyName = GetFullKeyName();
var svalue = scalar.Value?.ToString() ?? "\"\"";
state.Write("{0}=", keyName);
- var needQuotes = svalue.Contains(" ");
+ var needQuotes = svalue.Contains(" ") || svalue.Contains("=");
if (needQuotes)
{
switch (_options.DoubleQuotesAction)
diff --git a/TestApi/Startup.cs b/TestApi/Startup.cs
index cdb3fe2..73fab11 100644
--- a/TestApi/Startup.cs
+++ b/TestApi/Startup.cs
@@ -38,10 +38,13 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerF
var logger = lf.CreateLogger("Startup");
LogContext.PushProperty("complex", new { Name = @"Property ""DOUBLE QUOTES"" on it", When = DateTime.UtcNow, Value = 42, Sub = new { Name = "Test", Iv = 32 } }, true);
LogContext.PushProperty("str", "Simple string property");
+ LogContext.PushProperty("equals", "this=that");
LogContext.PushProperty("int", 42);
LogContext.PushProperty("test", new[] {10, 100, 1000});
var value = @"This value also have ""double quotes"" on it";
logger.LogInformation(@"Message with ""double quotes"" and a str value: {value} :) ", value);
+ logger.LogInformation("justalog");
+ logger.LogInformation("justalog=with=equals");
await context.Response.WriteAsync("Hello World!");
});
diff --git a/TestApi/Test.csproj b/TestApi/Test.csproj
index 2d5f033..ae58b57 100644
--- a/TestApi/Test.csproj
+++ b/TestApi/Test.csproj
@@ -1,7 +1,7 @@
- netcoreapp3.1
+ net6.0
13c18871-4940-4814-8884-4441168b3cea
Linux