Skip to content

Commit

Permalink
Remove netcoreapp2.1 from logging examples (open-telemetry#1993)
Browse files Browse the repository at this point in the history
  • Loading branch information
cijothomas authored Apr 16, 2021
1 parent 459cb6a commit aba4217
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 54 deletions.
2 changes: 1 addition & 1 deletion docs/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<!-- https://dotnet.microsoft.com/download/dotnet-core -->
<TargetFrameworks>netcoreapp2.1;netcoreapp3.1;net5.0</TargetFrameworks>
<TargetFrameworks>netcoreapp3.1;net5.0</TargetFrameworks>
<!-- https://dotnet.microsoft.com/download/dotnet-framework -->
<TargetFrameworks Condition="$(OS) == 'Windows_NT'">$(TargetFrameworks);net461;net462;net47;net471;net472;net48</TargetFrameworks>
</PropertyGroup>
Expand Down
12 changes: 0 additions & 12 deletions docs/logs/extending-the-sdk/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@
// </copyright>

using System.Collections.Generic;
#if NETCOREAPP2_1
using Microsoft.Extensions.DependencyInjection;
#endif
using Microsoft.Extensions.Logging;
using OpenTelemetry;
using OpenTelemetry.Logs;
Expand All @@ -26,11 +23,7 @@ public class Program
{
public static void Main()
{
#if NETCOREAPP2_1
var serviceCollection = new ServiceCollection().AddLogging(builder =>
#else
using var loggerFactory = LoggerFactory.Create(builder =>
#endif
builder.AddOpenTelemetry(options =>
{
options.IncludeScopes = true;
Expand All @@ -40,12 +33,7 @@ public static void Main()
.AddMyExporter();
}));

#if NETCOREAPP2_1
using var serviceProvider = serviceCollection.BuildServiceProvider();
var logger = serviceProvider.GetRequiredService<ILogger<Program>>();
#else
var logger = loggerFactory.CreateLogger<Program>();
#endif

// unstructured log
logger.LogInformation("Hello, World!");
Expand Down
7 changes: 1 addition & 6 deletions docs/logs/extending-the-sdk/extending-the-sdk.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,7 @@
<ProjectReference Include="$(RepoRoot)\src\OpenTelemetry\OpenTelemetry.csproj" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp2.1'">
<PackageReference Include="Microsoft.Extensions.Logging" Version="2.1.1" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="2.1.1" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' != 'netcoreapp2.1'">
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging" Version="$(MicrosoftExtensionsLoggingPkgVer)" />
</ItemGroup>
</Project>
13 changes: 0 additions & 13 deletions docs/logs/getting-started/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,33 +14,20 @@
// limitations under the License.
// </copyright>

#if NETCOREAPP2_1
using Microsoft.Extensions.DependencyInjection;
#endif
using Microsoft.Extensions.Logging;
using OpenTelemetry.Logs;

public class Program
{
public static void Main()
{
#if NETCOREAPP2_1
var serviceCollection = new ServiceCollection().AddLogging(builder =>
#else
using var loggerFactory = LoggerFactory.Create(builder =>
#endif
{
builder.AddOpenTelemetry(options => options
.AddConsoleExporter());
});

#if NETCOREAPP2_1
using var serviceProvider = serviceCollection.BuildServiceProvider();
var logger = serviceProvider.GetRequiredService<ILogger<Program>>();
#else
var logger = loggerFactory.CreateLogger<Program>();
#endif

logger.LogInformation("Hello from {name} {price}.", "tomato", 2.99);
}
}
18 changes: 2 additions & 16 deletions docs/logs/getting-started/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,29 +17,15 @@ You should see the following output:
Hello World!
```

Let's install the packages to get started with logging. If your ConsoleApp
targets `netcoreapp2.1` install the version `2.1.1` of
`Microsoft.Extensions.Logging` and `Microsoft.Extensions.DependencyInjection`
packages:

```sh
dotnet add package Microsoft.Extensions.Logging -v 2.1.1
```

```sh
dotnet add package Microsoft.Extensions.DependencyInjection -v 2.1.1
```

If your ConsoleApp targets a framework other than `netcoreapp2.1`, install the
latest Microsoft.Extensions.Logging package:
Install the latest `Microsoft.Extensions.Logging` package:

```sh
dotnet add package Microsoft.Extensions.Logging
```

Install the
[OpenTelemetry.Exporter.Console](../../../src/OpenTelemetry.Exporter.Console/README.md)
package (Use the latest version):
package:

```sh
dotnet add package OpenTelemetry.Exporter.Console
Expand Down
7 changes: 1 addition & 6 deletions docs/logs/getting-started/getting-started.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,7 @@
<ProjectReference Include="$(RepoRoot)\src\OpenTelemetry.Exporter.Console\OpenTelemetry.Exporter.Console.csproj" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp2.1'">
<PackageReference Include="Microsoft.Extensions.Logging" Version="2.1.1" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="2.1.1" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' != 'netcoreapp2.1'">
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging" Version="$(MicrosoftExtensionsLoggingPkgVer)" />
</ItemGroup>
</Project>

0 comments on commit aba4217

Please sign in to comment.