Update examples to support net8.0 (#4902)
This commit is contained in:
parent
f01db2bdfb
commit
eaf1d88021
|
|
@ -25,7 +25,7 @@
|
|||
<!-- non-production TFMs -->
|
||||
<TargetFrameworksForAspNetCoreTests>net8.0;net7.0;net6.0</TargetFrameworksForAspNetCoreTests>
|
||||
<TargetFrameworksForAotCompatibilityTests>net8.0</TargetFrameworksForAotCompatibilityTests>
|
||||
<TargetFrameworksForDocs>net7.0;net6.0</TargetFrameworksForDocs>
|
||||
<TargetFrameworksForDocs>net8.0;net7.0;net6.0</TargetFrameworksForDocs>
|
||||
<TargetFrameworksForDocs Condition="$(OS) == 'Windows_NT' And '$(UsingMicrosoftNETSdkWeb)' != 'True'">
|
||||
$(TargetFrameworksForDocs);net481;net48;net472;net471;net47;net462
|
||||
</TargetFrameworksForDocs>
|
||||
|
|
|
|||
|
|
@ -56,9 +56,9 @@ app.Run();
|
|||
|
||||
public static partial class ApplicationLogs
|
||||
{
|
||||
[LoggerMessage(EventId = 1, Level = LogLevel.Information, Message = "Starting the app...")]
|
||||
[LoggerMessage(LogLevel.Information, "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(LogLevel.Information, "Food `{name}` price changed to `{price}`.")]
|
||||
public static partial void FoodPriceChanged(this ILogger logger, string name, double price);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
...
|
||||
|
|
@ -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
|
||||
|
||||
...
|
||||
|
|
@ -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(LogLevel.Information, "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(LogLevel.Information, "Food `{name}` price changed to `{price}`.")]
|
||||
public static partial void FoodPriceChanged(this ILogger logger, string name, double price);
|
||||
}
|
||||
```
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Logging" />
|
||||
<ProjectReference Include="$(RepoRoot)\src\OpenTelemetry.Exporter.Console\OpenTelemetry.Exporter.Console.csproj" />
|
||||
<ProjectReference Include="$(RepoRoot)\src\OpenTelemetry.Extensions.Hosting\OpenTelemetry.Extensions.Hosting.csproj" />
|
||||
</ItemGroup>
|
||||
|
|
|
|||
|
|
@ -30,7 +30,6 @@ var logger = loggerFactory.CreateLogger<Program>();
|
|||
logger.FoodPriceChanged("artichoke", 9.99);
|
||||
|
||||
logger.FoodRecallNotice(
|
||||
logLevel: LogLevel.Critical,
|
||||
brandName: "Contoso",
|
||||
productDescription: "Salads",
|
||||
productType: "Food & Beverages",
|
||||
|
|
@ -43,13 +42,12 @@ loggerFactory.Dispose();
|
|||
|
||||
public static partial class ApplicationLogs
|
||||
{
|
||||
[LoggerMessage(EventId = 1, Level = LogLevel.Information, Message = "Food `{name}` price changed to `{price}`.")]
|
||||
[LoggerMessage(LogLevel.Information, "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(LogLevel.Critical, "A `{productType}` recall notice was published for `{brandName} {productDescription}` produced by `{companyName}` ({recallReasonDescription}).")]
|
||||
public static partial void FoodRecallNotice(
|
||||
this ILogger logger,
|
||||
LogLevel logLevel,
|
||||
string brandName,
|
||||
string productDescription,
|
||||
string productType,
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
...
|
||||
|
|
@ -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
|
||||
|
||||
...
|
||||
|
|
@ -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(LogLevel.Information, "Food `{name}` price changed to `{price}`.")]
|
||||
public static partial void FoodPriceChanged(this ILogger logger, string name, double price);
|
||||
|
||||
...
|
||||
|
|
|
|||
|
|
@ -37,6 +37,6 @@ loggerFactory.Dispose();
|
|||
|
||||
public static partial class ApplicationLogs
|
||||
{
|
||||
[LoggerMessage(EventId = 1, Level = LogLevel.Information, Message = "Food `{name}` price changed to `{price}`.")]
|
||||
[LoggerMessage(LogLevel.Information, "Food `{name}` price changed to `{price}`.")]
|
||||
public static partial void FoodPriceChanged(this ILogger logger, string name, double price);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue