diff --git a/src/Elastic.Apm.NLog/Elastic.Apm.NLog.csproj b/src/Elastic.Apm.NLog/Elastic.Apm.NLog.csproj index 4ac2c472..4d581868 100644 --- a/src/Elastic.Apm.NLog/Elastic.Apm.NLog.csproj +++ b/src/Elastic.Apm.NLog/Elastic.Apm.NLog.csproj @@ -1,6 +1,6 @@ - netstandard2.0;net462 + netstandard2.0;net462;net8.0 Elastic APM NLog Layout Renderers Enrich NLog log messages with APM TraceId and TransactionId. True diff --git a/src/Elastic.Apm.SerilogEnricher/Elastic.Apm.SerilogEnricher.csproj b/src/Elastic.Apm.SerilogEnricher/Elastic.Apm.SerilogEnricher.csproj index af8ff34f..774e6b10 100644 --- a/src/Elastic.Apm.SerilogEnricher/Elastic.Apm.SerilogEnricher.csproj +++ b/src/Elastic.Apm.SerilogEnricher/Elastic.Apm.SerilogEnricher.csproj @@ -1,6 +1,6 @@ - netstandard2.0;net462 + netstandard2.0;net462;net8.0 Elastic APM Serilog Enricher Enrich Serilog log messages with APM TraceId and TransactionId. True diff --git a/src/Elastic.CommonSchema.Log4net/Elastic.CommonSchema.Log4net.csproj b/src/Elastic.CommonSchema.Log4net/Elastic.CommonSchema.Log4net.csproj index d8bdaf60..fe10dd08 100644 --- a/src/Elastic.CommonSchema.Log4net/Elastic.CommonSchema.Log4net.csproj +++ b/src/Elastic.CommonSchema.Log4net/Elastic.CommonSchema.Log4net.csproj @@ -1,7 +1,7 @@ - netstandard2.0;netstandard2.1;net462 + netstandard2.0;netstandard2.1;net462;net8.0 Elastic Common Schema (ECS) log4net Layout log4net Layout that formats log events in accordance with Elastic Common Schema (ECS). True diff --git a/src/Elastic.CommonSchema.NLog/Elastic.CommonSchema.NLog.csproj b/src/Elastic.CommonSchema.NLog/Elastic.CommonSchema.NLog.csproj index 19b5c078..05249fe6 100644 --- a/src/Elastic.CommonSchema.NLog/Elastic.CommonSchema.NLog.csproj +++ b/src/Elastic.CommonSchema.NLog/Elastic.CommonSchema.NLog.csproj @@ -1,7 +1,7 @@ - netstandard2.0;netstandard2.1;net462 + netstandard2.0;netstandard2.1;net462;net8.0 Elastic Common Schema (ECS) NLog Layout NLog Layout that formats log events in accordance with Elastic Common Schema (ECS). True diff --git a/src/Elastic.CommonSchema.Serilog/Elastic.CommonSchema.Serilog.csproj b/src/Elastic.CommonSchema.Serilog/Elastic.CommonSchema.Serilog.csproj index 8aa33727..c021f533 100644 --- a/src/Elastic.CommonSchema.Serilog/Elastic.CommonSchema.Serilog.csproj +++ b/src/Elastic.CommonSchema.Serilog/Elastic.CommonSchema.Serilog.csproj @@ -2,7 +2,7 @@ - netstandard2.0;netstandard2.1;net462 + netstandard2.0;netstandard2.1;net462;net8.0 Elastic Common Schema (ECS) Serilog Formatter Serilog TextFormatter that formats log events in accordance with Elastic Common Schema (ECS). True diff --git a/src/Elastic.CommonSchema.Serilog/LogEventConverter.cs b/src/Elastic.CommonSchema.Serilog/LogEventConverter.cs index 14decb3d..510346a3 100644 --- a/src/Elastic.CommonSchema.Serilog/LogEventConverter.cs +++ b/src/Elastic.CommonSchema.Serilog/LogEventConverter.cs @@ -183,11 +183,11 @@ private static object PropertyValueToObject(LogEventPropertyValue propertyValue) switch (propertyValue) { case SequenceValue values: - return values.Elements.Select(PropertyValueToObject).ToArray(); + return values.Elements.Select((e) => PropertyValueToObject(e)).ToArray(); case ScalarValue sv: return sv.Value; case DictionaryValue dv: - return dv.Elements.ToDictionary(keySelector: kvp => kvp.Key.Value.ToString(), + return dv.Elements.ToDictionary(keySelector: kvp => kvp.Key.Value.ToString() ?? string.Empty, elementSelector: (kvp) => PropertyValueToObject(kvp.Value)); case StructureValue ov: { diff --git a/src/Elastic.CommonSchema/Elastic.CommonSchema.csproj b/src/Elastic.CommonSchema/Elastic.CommonSchema.csproj index d2341cd9..ad476637 100644 --- a/src/Elastic.CommonSchema/Elastic.CommonSchema.csproj +++ b/src/Elastic.CommonSchema/Elastic.CommonSchema.csproj @@ -1,7 +1,7 @@ - netstandard2.0;netstandard2.1;net462;net6.0 + netstandard2.0;netstandard2.1;net462;net8.0 Elastic Common Schema (ECS) Types Maps Elastic Common Schema (ECS) to .NET types including (de)serialization using System.Text.Json latest @@ -14,10 +14,9 @@ runtime; build; native; contentfiles; analyzers; buildtransitive - - + + - diff --git a/src/Elastic.Extensions.Logging.Common/Elastic.Extensions.Logging.Common.csproj b/src/Elastic.Extensions.Logging.Common/Elastic.Extensions.Logging.Common.csproj index 81237a3d..6dabd925 100644 --- a/src/Elastic.Extensions.Logging.Common/Elastic.Extensions.Logging.Common.csproj +++ b/src/Elastic.Extensions.Logging.Common/Elastic.Extensions.Logging.Common.csproj @@ -1,7 +1,7 @@ - netstandard2.0;netstandard2.1 + netstandard2.0;netstandard2.1;net8.0 Common Abstactions For ECS For Microsoft.Extensions.Logging Transient dependency, do not install directly. Common Abstactions For ECS For Microsoft.Extensions.Logging Logging;LoggerProvider;Elasticsearch;Console;ELK;Kibana;Logstash;Tracing;Diagnostics;Log;Trace;ECS @@ -13,8 +13,9 @@ + - + diff --git a/src/Elastic.Extensions.Logging.Common/LogEventBuilderExtensions.cs b/src/Elastic.Extensions.Logging.Common/LogEventBuilderExtensions.cs index 4f56e458..54c5ddd8 100644 --- a/src/Elastic.Extensions.Logging.Common/LogEventBuilderExtensions.cs +++ b/src/Elastic.Extensions.Logging.Common/LogEventBuilderExtensions.cs @@ -21,7 +21,7 @@ void AddScopeValue(TLocalState scope, LogEvent log) var scopeValues = (scope as IEnumerable>)?.ToList(); var scopeName = scopeValues != null && scopeValues.Any(kv => kv.Key == "{OriginalFormat}") - ? scope.ToString() + ? (scope.ToString() ?? string.Empty) : FormatValue(scope, options, 0, scope.GetType().Name); log.Scopes.Add(scopeName); @@ -139,7 +139,7 @@ private static string FormatValue(object value, ILogEventCreationOptions options if (depth < 1 && value is IEnumerable enumerable) return FormatEnumerable(enumerable, depth, options); - return defaultFallback ?? value.ToString(); + return defaultFallback ?? value.ToString() ?? string.Empty; } } diff --git a/src/Elastic.Extensions.Logging.Console/Elastic.Extensions.Logging.Console.csproj b/src/Elastic.Extensions.Logging.Console/Elastic.Extensions.Logging.Console.csproj index 24cd88a8..5a66ae52 100644 --- a/src/Elastic.Extensions.Logging.Console/Elastic.Extensions.Logging.Console.csproj +++ b/src/Elastic.Extensions.Logging.Console/Elastic.Extensions.Logging.Console.csproj @@ -1,7 +1,7 @@ - netstandard2.0;netstandard2.1 + netstandard2.0;netstandard2.1;net8.0 enable ECS Console Logger for Microsoft.Extensions.Logging ECS Console Logger for Microsoft.Extensions.Logging. Writes Elastic Common Schema (ECS), with semantic logging of structured data from message and scope values to console out, use filebeat/Elastic-Agent to send these to Elastic @@ -11,7 +11,7 @@ - + diff --git a/src/Elastic.Extensions.Logging/Elastic.Extensions.Logging.csproj b/src/Elastic.Extensions.Logging/Elastic.Extensions.Logging.csproj index 3b153ac8..102b94fd 100644 --- a/src/Elastic.Extensions.Logging/Elastic.Extensions.Logging.csproj +++ b/src/Elastic.Extensions.Logging/Elastic.Extensions.Logging.csproj @@ -1,7 +1,7 @@ - netstandard2.0;netstandard2.1 + netstandard2.0;netstandard2.1;net8.0 Elasticsearch Logger Provider Elasticsearch logger provider for Microsoft.Extensions.Logging. Writes direct to Elasticsearch using the Elastic Common Schema (ECS), with semantic logging of structured data from message and scope values, for use with the Elasticsearch-Logstash-Kibana (ELK) stack. The results can be viewed and queried in the Kibana console. Logging;LoggerProvider;Elasticsearch;ELK;Kibana;Logstash;Tracing;Diagnostics;Log;Trace;ECS @@ -10,7 +10,7 @@ - + diff --git a/src/Elastic.Extensions.Logging/ElasticsearchLogger.cs b/src/Elastic.Extensions.Logging/ElasticsearchLogger.cs index 30d1f8ff..c12084a0 100644 --- a/src/Elastic.Extensions.Logging/ElasticsearchLogger.cs +++ b/src/Elastic.Extensions.Logging/ElasticsearchLogger.cs @@ -43,14 +43,14 @@ internal ElasticsearchLogger( _scopeProvider = scopeProvider; } - private class EmptyDisposable : IDisposable + private sealed class EmptyDisposable : IDisposable { public void Dispose() { } } private readonly IDisposable _emptyScope = new EmptyDisposable(); /// - public IDisposable BeginScope(TState state) => _scopeProvider?.Push(state) ?? _emptyScope; + IDisposable ILogger.BeginScope(TState state) => _scopeProvider?.Push(state) ?? _emptyScope; /// public bool IsEnabled(LogLevel logLevel) => _options.IsEnabled; diff --git a/src/Elastic.Extensions.Logging/ElasticsearchLoggerProvider.cs b/src/Elastic.Extensions.Logging/ElasticsearchLoggerProvider.cs index 18803a5f..97c2af72 100644 --- a/src/Elastic.Extensions.Logging/ElasticsearchLoggerProvider.cs +++ b/src/Elastic.Extensions.Logging/ElasticsearchLoggerProvider.cs @@ -20,10 +20,6 @@ using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; -#if NETSTANDARD2_1_OR_GREATER -using System.Buffers; -#endif - namespace Elastic.Extensions.Logging { /// @@ -35,14 +31,14 @@ public class ElasticsearchLoggerProvider : ILoggerProvider, ISupportExternalScop { private readonly IChannelSetup[] _channelConfigurations; private readonly IOptionsMonitor _options; - private readonly IDisposable _optionsReloadToken; + private readonly IDisposable? _optionsReloadToken; private IExternalScopeProvider? _scopeProvider; private IBufferedChannel _shipper; private static readonly LogEventWriter LogEventWriterInstance = new() { WriteToStreamAsync = static async (stream, logEvent, ctx) => await logEvent.SerializeAsync(stream, ctx).ConfigureAwait(false), -#if NETSTANDARD2_1_OR_GREATER +#if NETSTANDARD2_1_OR_GREATER || NET8_0_OR_GREATER WriteToArrayBuffer = static (arrayBufferWriter, logEvent) => { var serialized = logEvent.SerializeToUtf8Bytes(); // TODO - Performance optimisation to avoid array allocation @@ -84,7 +80,7 @@ public ILogger CreateLogger(string name) => /// public void Dispose() { - _optionsReloadToken.Dispose(); + _optionsReloadToken?.Dispose(); _shipper.Dispose(); } @@ -216,8 +212,8 @@ private IBufferedChannel CreatIngestChannel(ElasticsearchLoggerOptions private sealed class LogEventWriter : IElasticsearchEventWriter { -#if NETSTANDARD2_1_OR_GREATER - public Action, LogEvent>? WriteToArrayBuffer { get; set; } +#if NETSTANDARD2_1_OR_GREATER || NET8_0_OR_GREATER + public Action, LogEvent>? WriteToArrayBuffer { get; set; } #endif public Func? WriteToStreamAsync { get; set; } diff --git a/src/Elastic.Ingest.Elasticsearch.CommonSchema/Elastic.Ingest.Elasticsearch.CommonSchema.csproj b/src/Elastic.Ingest.Elasticsearch.CommonSchema/Elastic.Ingest.Elasticsearch.CommonSchema.csproj index aab40925..46d055a1 100644 --- a/src/Elastic.Ingest.Elasticsearch.CommonSchema/Elastic.Ingest.Elasticsearch.CommonSchema.csproj +++ b/src/Elastic.Ingest.Elasticsearch.CommonSchema/Elastic.Ingest.Elasticsearch.CommonSchema.csproj @@ -1,7 +1,7 @@ - netstandard2.0;netstandard2.1 + netstandard2.0;netstandard2.1;net8.0 True diff --git a/src/Elastic.NLog.Targets/Elastic.NLog.Targets.csproj b/src/Elastic.NLog.Targets/Elastic.NLog.Targets.csproj index bc8c9086..de14d2ab 100644 --- a/src/Elastic.NLog.Targets/Elastic.NLog.Targets.csproj +++ b/src/Elastic.NLog.Targets/Elastic.NLog.Targets.csproj @@ -1,7 +1,7 @@ - netstandard2.0 + netstandard2.0;netstandard2.1;net8.0 Elasticsearch NLog Target NLog Target that exports directly to Elastic Cloud or individual Elasticsearch nodes NLog.Targets diff --git a/src/Elastic.Serilog.Enrichers.Web/Elastic.Serilog.Enrichers.Web.csproj b/src/Elastic.Serilog.Enrichers.Web/Elastic.Serilog.Enrichers.Web.csproj index c89f54de..d1bce2e0 100644 --- a/src/Elastic.Serilog.Enrichers.Web/Elastic.Serilog.Enrichers.Web.csproj +++ b/src/Elastic.Serilog.Enrichers.Web/Elastic.Serilog.Enrichers.Web.csproj @@ -1,7 +1,7 @@ - + - net6.0;net8.0;net462 + net8.0;net462 enable enable Elastic Common Schema (ECS) Serilog Enricher for Web proeprties diff --git a/src/Elastic.Serilog.Sinks/Elastic.Serilog.Sinks.csproj b/src/Elastic.Serilog.Sinks/Elastic.Serilog.Sinks.csproj index 439834e6..dbc21715 100644 --- a/src/Elastic.Serilog.Sinks/Elastic.Serilog.Sinks.csproj +++ b/src/Elastic.Serilog.Sinks/Elastic.Serilog.Sinks.csproj @@ -1,7 +1,7 @@ - netstandard2.0;netstandard2.1 + netstandard2.0;netstandard2.1;net8.0 enable True diff --git a/tests/Elastic.CommonSchema.Serilog.Tests/Elastic.CommonSchema.Serilog.Tests.csproj b/tests/Elastic.CommonSchema.Serilog.Tests/Elastic.CommonSchema.Serilog.Tests.csproj index 9e917b57..22ea21df 100644 --- a/tests/Elastic.CommonSchema.Serilog.Tests/Elastic.CommonSchema.Serilog.Tests.csproj +++ b/tests/Elastic.CommonSchema.Serilog.Tests/Elastic.CommonSchema.Serilog.Tests.csproj @@ -8,7 +8,7 @@ - + diff --git a/tests/Elastic.CommonSchema.Tests/Elastic.CommonSchema.Tests.csproj b/tests/Elastic.CommonSchema.Tests/Elastic.CommonSchema.Tests.csproj index 71a4eeb8..0e7d3ae1 100644 --- a/tests/Elastic.CommonSchema.Tests/Elastic.CommonSchema.Tests.csproj +++ b/tests/Elastic.CommonSchema.Tests/Elastic.CommonSchema.Tests.csproj @@ -1,7 +1,7 @@ - + - net8.0;net6.0 + net8.0 false diff --git a/tests/Elastic.Serilog.Sinks.Tests/Elastic.Serilog.Sinks.Tests.csproj b/tests/Elastic.Serilog.Sinks.Tests/Elastic.Serilog.Sinks.Tests.csproj index 1e76d668..bfd6ba89 100644 --- a/tests/Elastic.Serilog.Sinks.Tests/Elastic.Serilog.Sinks.Tests.csproj +++ b/tests/Elastic.Serilog.Sinks.Tests/Elastic.Serilog.Sinks.Tests.csproj @@ -1,7 +1,7 @@ - net6.0 + net8.0 enable enable preview @@ -12,8 +12,8 @@ - - + +