Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
update examples to support net8.0
  • Loading branch information
reyang committed Sep 29, 2023
commit 621839c97dc1490c43d38b2beddeb2dfd90c7ef3
2 changes: 1 addition & 1 deletion docs/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<OutputType>Exe</OutputType>
<!-- https://dotnet.microsoft.com/download/dotnet-core -->
<!-- OmniSharp/VS Code requires TargetFrameworks to be in descending order for IntelliSense and analysis. -->
<TargetFrameworks>net7.0;net6.0</TargetFrameworks>
<TargetFrameworks>net8.0;net7.0;net6.0</TargetFrameworks>
<!-- https://dotnet.microsoft.com/download/dotnet-framework -->
<TargetFrameworks Condition="$(OS) == 'Windows_NT'">$(TargetFrameworks);net462;net47;net471;net472;net48</TargetFrameworks>
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion docs/Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project>
<Import Project="$([MSBuild]::GetPathOfFileAbove(Directory.Packages.props, $(MSBuildThisFileDirectory)..))" />
<ItemGroup>
<PackageVersion Update="Microsoft.Extensions.Logging" Version="[6.0.0,)" />
<PackageVersion Update="Microsoft.Extensions.Logging" Version="[8.0.0-rc.1.23419.4,)" />
</ItemGroup>
</Project>
4 changes: 2 additions & 2 deletions docs/logs/getting-started-aspnetcore/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@

public static partial class ApplicationLogs
{
[LoggerMessage(EventId = 1, Level = LogLevel.Information, Message = "Starting the app...")]
[LoggerMessage(Level = LogLevel.Information, Message = "Starting the app...")]
public static partial void StartingApp(this ILogger logger);

[LoggerMessage(EventId = 2, Level = LogLevel.Information, Message = "Food `{name}` price changed to `{price}`.")]
[LoggerMessage(Level = LogLevel.Information, Message = "Food `{name}` price changed to `{price}`.")]
public static partial void FoodPriceChanged(this ILogger logger, string name, double price);
}
20 changes: 4 additions & 16 deletions docs/logs/getting-started-aspnetcore/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ LogRecord.SeverityText: Information
LogRecord.Body: Starting the app...
LogRecord.Attributes (Key:Value):
OriginalFormat (a.k.a Body): Starting the app...
LogRecord.EventId: 1
LogRecord.EventId: 225744744
LogRecord.EventName: StartingApp

...
Expand Down Expand Up @@ -65,7 +65,7 @@ LogRecord.Attributes (Key:Value):
name: artichoke
price: 9.99
OriginalFormat (a.k.a Body): Food `{name}` price changed to `{price}`.
LogRecord.EventId: 2
LogRecord.EventId: 344095174
LogRecord.EventName: FoodPriceChanged

...
Expand Down Expand Up @@ -110,10 +110,10 @@ logging, and type-checked parameters:
```csharp
public static partial class ApplicationLogs
{
[LoggerMessage(EventId = 1, Level = LogLevel.Information, Message = "Starting the app...")]
[LoggerMessage(Level = LogLevel.Information, Message = "Starting the app...")]
public static partial void StartingApp(this ILogger logger);

[LoggerMessage(EventId = 2, Level = LogLevel.Information, Message = "Food `{name}` price changed to `{price}`.")]
[LoggerMessage(Level = LogLevel.Information, Message = "Food `{name}` price changed to `{price}`.")]
public static partial void FoodPriceChanged(this ILogger logger, string name, double price);
}
```
Expand All @@ -125,18 +125,6 @@ generic `ILogger<T>` is not an option, `app.Logger` is used instead:
app.Logger.StartingApp();
```

> **Note**
> There are cases where logging is needed before the [dependency injection
(DI)](https://learn.microsoft.com/dotnet/core/extensions/dependency-injection)
logging pipeline is available (e.g. before `builder.Build()`) or after the DI
logging pipeline is disposed (e.g. after `app.Run()`). The common practice is to
use a separate logging pipeline by creating a `LoggerFactory` instance.
>
> Refer to the [Getting Started with OpenTelemetry .NET Logs in 5 Minutes -
Console Application](../getting-started-console/README.md) tutorial to learn
more about how to create a `LoggerFactory` instance and configure OpenTelemetry
to work with it.

## Learn more

* [Compile-time logging source
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFrameworks>net6.0;net7.0</TargetFrameworks>
<TargetFrameworks>net8.0;net7.0;net6.0</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions docs/logs/getting-started-console/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@

public static partial class ApplicationLogs
{
[LoggerMessage(EventId = 1, Level = LogLevel.Information, Message = "Food `{name}` price changed to `{price}`.")]
[LoggerMessage(Level = LogLevel.Information, Message = "Food `{name}` price changed to `{price}`.")]
public static partial void FoodPriceChanged(this ILogger logger, string name, double price);

[LoggerMessage(EventId = 2, Message = "A `{productType}` recall notice was published for `{brandName} {productDescription}` produced by `{companyName}` ({recallReasonDescription}).")]
[LoggerMessage(Message = "A `{productType}` recall notice was published for `{brandName} {productDescription}` produced by `{companyName}` ({recallReasonDescription}).")]
public static partial void FoodRecallNotice(
this ILogger logger,
LogLevel logLevel,
Expand Down
6 changes: 3 additions & 3 deletions docs/logs/getting-started-console/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ LogRecord.Attributes (Key:Value):
name: artichoke
price: 9.99
OriginalFormat (a.k.a Body): Food `{name}` price changed to `{price}`.
LogRecord.EventId: 1
LogRecord.EventId: 344095174
LogRecord.EventName: FoodPriceChanged

...
Expand All @@ -60,7 +60,7 @@ LogRecord.Attributes (Key:Value):
recallReasonDescription: due to a possible health risk from Listeria monocytogenes
companyName: Contoso Fresh Vegetables, Inc.
OriginalFormat (a.k.a Body): A `{productType}` recall notice was published for `{brandName} {productDescription}` produced by `{companyName}` ({recallReasonDescription}).
LogRecord.EventId: 2
LogRecord.EventId: 1338249384
LogRecord.EventName: FoodRecallNotice

...
Expand Down Expand Up @@ -93,7 +93,7 @@ logging, and type-checked parameters:
```csharp
public static partial class ApplicationLogs
{
[LoggerMessage(EventId = 1, Level = LogLevel.Information, Message = "Food `{name}` price changed to `{price}`.")]
[LoggerMessage(Level = LogLevel.Information, Message = "Food `{name}` price changed to `{price}`.")]
public static partial void FoodPriceChanged(this ILogger logger, string name, double price);

...
Expand Down
2 changes: 1 addition & 1 deletion docs/logs/redaction/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@

public static partial class ApplicationLogs
{
[LoggerMessage(EventId = 1, Level = LogLevel.Information, Message = "Food `{name}` price changed to `{price}`.")]
[LoggerMessage(Level = LogLevel.Information, Message = "Food `{name}` price changed to `{price}`.")]
public static partial void FoodPriceChanged(this ILogger logger, string name, double price);
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFrameworks>net6.0;net7.0</TargetFrameworks>
<TargetFrameworks>net8.0;net7.0;net6.0</TargetFrameworks>
</PropertyGroup>

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

<PropertyGroup>
<TargetFrameworks>net6.0;net7.0</TargetFrameworks>
<TargetFrameworks>net8.0;net7.0;net6.0</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
Expand Down