Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update examples to support net8.0 #4902

Merged
merged 13 commits into from
Oct 6, 2023
2 changes: 1 addition & 1 deletion build/Common.props
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
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(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);
}
8 changes: 4 additions & 4 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
reyang marked this conversation as resolved.
Show resolved Hide resolved
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(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);
}
```
Expand Down
Original file line number Diff line number Diff line change
@@ -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>
Expand Down
6 changes: 2 additions & 4 deletions docs/logs/getting-started-console/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
logger.FoodPriceChanged("artichoke", 9.99);

logger.FoodRecallNotice(
logLevel: LogLevel.Critical,
brandName: "Contoso",
productDescription: "Salads",
productType: "Food & Beverages",
Expand All @@ -43,13 +42,12 @@

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,
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(LogLevel.Information, "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(LogLevel.Information, "Food `{name}` price changed to `{price}`.")]
public static partial void FoodPriceChanged(this ILogger logger, string name, double price);
}
Loading