Skip to content

Commit

Permalink
Updated to NET8 since NET6 is obsolete
Browse files Browse the repository at this point in the history
  • Loading branch information
snakefoot committed Jan 7, 2025
1 parent 69c93bc commit 16dee0c
Show file tree
Hide file tree
Showing 20 changed files with 36 additions and 40 deletions.
2 changes: 1 addition & 1 deletion src/Elastic.Apm.NLog/Elastic.Apm.NLog.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net462</TargetFrameworks>
<TargetFrameworks>netstandard2.0;net462;net8.0</TargetFrameworks>
<Title>Elastic APM NLog Layout Renderers</Title>
<Description>Enrich NLog log messages with APM TraceId and TransactionId.</Description>
<IsPackable>True</IsPackable>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net462</TargetFrameworks>
<TargetFrameworks>netstandard2.0;net462;net8.0</TargetFrameworks>
<Title>Elastic APM Serilog Enricher</Title>
<Description>Enrich Serilog log messages with APM TraceId and TransactionId.</Description>
<IsPackable>True</IsPackable>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;netstandard2.1;net462</TargetFrameworks>
<TargetFrameworks>netstandard2.0;netstandard2.1;net462;net8.0</TargetFrameworks>
<Title>Elastic Common Schema (ECS) log4net Layout</Title>
<Description>log4net Layout that formats log events in accordance with Elastic Common Schema (ECS).</Description>
<IsPackable>True</IsPackable>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;netstandard2.1;net462</TargetFrameworks>
<TargetFrameworks>netstandard2.0;netstandard2.1;net462;net8.0</TargetFrameworks>
<Title>Elastic Common Schema (ECS) NLog Layout</Title>
<Description>NLog Layout that formats log events in accordance with Elastic Common Schema (ECS).</Description>
<IsPackable>True</IsPackable>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;netstandard2.1;net462</TargetFrameworks>
<TargetFrameworks>netstandard2.0;netstandard2.1;net462;net8.0</TargetFrameworks>
<Title>Elastic Common Schema (ECS) Serilog Formatter</Title>
<Description>Serilog TextFormatter that formats log events in accordance with Elastic Common Schema (ECS).</Description>
<IsPackable>True</IsPackable>
Expand Down
4 changes: 2 additions & 2 deletions src/Elastic.CommonSchema.Serilog/LogEventConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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:
{
Expand Down
7 changes: 3 additions & 4 deletions src/Elastic.CommonSchema/Elastic.CommonSchema.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;netstandard2.1;net462;net6.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;netstandard2.1;net462;net8.0</TargetFrameworks>
<Title>Elastic Common Schema (ECS) Types</Title>
<Description>Maps Elastic Common Schema (ECS) to .NET types including (de)serialization using System.Text.Json</Description>
<LangVersion>latest</LangVersion>
Expand All @@ -14,10 +14,9 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
<ItemGroup Condition="$(TargetFramework) == 'net462' OR $(TargetFramework) == 'netstandard2.0' OR $(TargetFramework) == 'netstandard2.1'">
<PackageReference Include="System.Diagnostics.DiagnosticSource" Version="5.0.0" />
<ItemGroup Condition=" $(TargetFramework.StartsWith('netstandard2.')) OR $(TargetFramework.StartsWith('net4')) ">
<PackageReference Include="System.Diagnostics.DiagnosticSource" Version="8.0.0" />
<PackageReference Include="System.Text.Json" Version="8.0.5" />

</ItemGroup>
<ItemGroup>
<Compile Include="..\NullableExtensions.cs" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0;netstandard2.1</TargetFrameworks>
<TargetFrameworks>netstandard2.0;netstandard2.1;net8.0</TargetFrameworks>
<Title>Common Abstactions For ECS For Microsoft.Extensions.Logging</Title>
<Description>Transient dependency, do not install directly. Common Abstactions For ECS For Microsoft.Extensions.Logging</Description>
<PackageTags>Logging;LoggerProvider;Elasticsearch;Console;ELK;Kibana;Logstash;Tracing;Diagnostics;Log;Trace;ECS</PackageTags>
Expand All @@ -13,8 +13,9 @@
<ItemGroup>
<ProjectReference Include="..\Elastic.CommonSchema\Elastic.CommonSchema.csproj"/>
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging" Version="6.0.0"/>
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0"/>
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ void AddScopeValue<TLocalState>(TLocalState scope, LogEvent log)

var scopeValues = (scope as IEnumerable<KeyValuePair<string, object>>)?.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);

Expand Down Expand Up @@ -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;
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0;netstandard2.1</TargetFrameworks>
<TargetFrameworks>netstandard2.0;netstandard2.1;net8.0</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Title>ECS Console Logger for Microsoft.Extensions.Logging</Title>
<Description>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</Description>
Expand All @@ -11,7 +11,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="6.0.0"/>
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="8.0.0"/>
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging.Configuration" Version="2.1.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Configuration" Version="8.0.0" />
<ProjectReference Include="..\Elastic.CommonSchema\Elastic.CommonSchema.csproj" />
<ProjectReference Include="..\Elastic.Extensions.Logging.Common\Elastic.Extensions.Logging.Common.csproj" />
<ProjectReference Include="..\Elastic.Ingest.Elasticsearch.CommonSchema\Elastic.Ingest.Elasticsearch.CommonSchema.csproj" />
Expand Down
4 changes: 2 additions & 2 deletions src/Elastic.Extensions.Logging/ElasticsearchLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();

/// <inheritdoc cref="ILogger.BeginScope{TState}"/>
public IDisposable BeginScope<TState>(TState state) => _scopeProvider?.Push(state) ?? _emptyScope;
IDisposable ILogger.BeginScope<TState>(TState state) => _scopeProvider?.Push(state) ?? _emptyScope;

/// <inheritdoc cref="ILogger.IsEnabled"/>
public bool IsEnabled(LogLevel logLevel) => _options.IsEnabled;
Expand Down
14 changes: 5 additions & 9 deletions src/Elastic.Extensions.Logging/ElasticsearchLoggerProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
/// <summary>
Expand All @@ -35,14 +31,14 @@ public class ElasticsearchLoggerProvider : ILoggerProvider, ISupportExternalScop
{
private readonly IChannelSetup[] _channelConfigurations;
private readonly IOptionsMonitor<ElasticsearchLoggerOptions> _options;
private readonly IDisposable _optionsReloadToken;
private readonly IDisposable? _optionsReloadToken;
private IExternalScopeProvider? _scopeProvider;
private IBufferedChannel<LogEvent> _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
Expand Down Expand Up @@ -84,7 +80,7 @@ public ILogger CreateLogger(string name) =>
/// <inheritdoc cref="IDisposable.Dispose"/>
public void Dispose()
{
_optionsReloadToken.Dispose();
_optionsReloadToken?.Dispose();
_shipper.Dispose();
}

Expand Down Expand Up @@ -216,8 +212,8 @@ private IBufferedChannel<LogEvent> CreatIngestChannel(ElasticsearchLoggerOptions

private sealed class LogEventWriter : IElasticsearchEventWriter<LogEvent>
{
#if NETSTANDARD2_1_OR_GREATER
public Action<ArrayBufferWriter<byte>, LogEvent>? WriteToArrayBuffer { get; set; }
#if NETSTANDARD2_1_OR_GREATER || NET8_0_OR_GREATER
public Action<System.Buffers.ArrayBufferWriter<byte>, LogEvent>? WriteToArrayBuffer { get; set; }
#endif

public Func<Stream, LogEvent, CancellationToken, Task>? WriteToStreamAsync { get; set; }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0;netstandard2.1</TargetFrameworks>
<TargetFrameworks>netstandard2.0;netstandard2.1;net8.0</TargetFrameworks>
<IsPackable>True</IsPackable>
</PropertyGroup>

Expand Down
2 changes: 1 addition & 1 deletion src/Elastic.NLog.Targets/Elastic.NLog.Targets.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;netstandard2.1;net8.0</TargetFrameworks>
<Title>Elasticsearch NLog Target</Title>
<Description>NLog Target that exports directly to Elastic Cloud or individual Elasticsearch nodes</Description>
<RootNamespace>NLog.Targets</RootNamespace>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6.0;net8.0;net462</TargetFrameworks>
<TargetFrameworks>net8.0;net462</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Title>Elastic Common Schema (ECS) Serilog Enricher for Web proeprties</Title>
Expand Down
2 changes: 1 addition & 1 deletion src/Elastic.Serilog.Sinks/Elastic.Serilog.Sinks.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0;netstandard2.1</TargetFrameworks>
<TargetFrameworks>netstandard2.0;netstandard2.1;net8.0</TargetFrameworks>
<Nullable>enable</Nullable>
<IsPackable>True</IsPackable>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.0" />
<PackageReference Include="Serilog.Enrichers.Environment" Version="2.1.3" />
<PackageReference Include="Serilog.Enrichers.Process" Version="2.0.1" />
<PackageReference Include="Serilog.Enrichers.Thread" Version="3.2.0-dev-00747" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net8.0;net6.0</TargetFrameworks>
<TargetFrameworks>net8.0</TargetFrameworks>
<IsPackable>false</IsPackable>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<LangVersion>preview</LangVersion>
Expand All @@ -12,8 +12,8 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Configuration" Version="7.0.0"/>
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="7.0.0"/>
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0"/>
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.1"/>
<PackageReference Include="Serilog.Settings.Configuration" Version="8.0.2"/>
</ItemGroup>

Expand Down

0 comments on commit 16dee0c

Please sign in to comment.