Nandel.Extensions.Serilog.GoogleAgentTextFormatter
1.0.0-alpha.2
dotnet add package Nandel.Extensions.Serilog.GoogleAgentTextFormatter --version 1.0.0-alpha.2
NuGet\Install-Package Nandel.Extensions.Serilog.GoogleAgentTextFormatter -Version 1.0.0-alpha.2
<PackageReference Include="Nandel.Extensions.Serilog.GoogleAgentTextFormatter" Version="1.0.0-alpha.2" />
<PackageVersion Include="Nandel.Extensions.Serilog.GoogleAgentTextFormatter" Version="1.0.0-alpha.2" />
<PackageReference Include="Nandel.Extensions.Serilog.GoogleAgentTextFormatter" />
paket add Nandel.Extensions.Serilog.GoogleAgentTextFormatter --version 1.0.0-alpha.2
#r "nuget: Nandel.Extensions.Serilog.GoogleAgentTextFormatter, 1.0.0-alpha.2"
#:package Nandel.Extensions.Serilog.GoogleAgentTextFormatter@1.0.0-alpha.2
#addin nuget:?package=Nandel.Extensions.Serilog.GoogleAgentTextFormatter&version=1.0.0-alpha.2&prerelease
#tool nuget:?package=Nandel.Extensions.Serilog.GoogleAgentTextFormatter&version=1.0.0-alpha.2&prerelease
GoogleAgentTextFormatter for Serilog
The GoogleAgentTextFormatter is a custom Serilog text formatter that formats log events in a way that is compatible with Google Cloud Platform (GCP) logging services. This formatter allows your application logs to be interpreted correctly by GCP solutions like Cloud Run, enabling seamless integration with Google Cloud Platform monitoring tools.
Installation
To install the Nandel.Extensions.Serilog.GoogleAgentTextFormatter NuGet package, run the following command in your package manager console:
Install-Package Nandel.Extensions.Serilog.GoogleAgentTextFormatter
Alternatively, you can add it to your project file (.csproj) directly:
<PackageReference Include="Nandel.Extensions.Serilog.GoogleAgentTextFormatter" Version="1.0.0-alpha.2" />
Usage
1. In Code
To use the GoogleAgentTextFormatter in your application, you need to configure Serilog to use this formatter. Here’s an example of how to set it up in your code:
using Serilog;
class Program
{
static void Main(string[] args)
{
Log.Logger = new LoggerConfiguration()
.WriteTo.Console(new GoogleAgentTextFormatter()) // Updated formatter
.CreateLogger();
Log.Information("This is an information log.");
Log.Error("This is an error log with an exception.", new Exception("Sample exception"));
Log.CloseAndFlush();
}
}
2. Using App Settings
You can also configure the GoogleAgentTextFormatter through your application settings (e.g., appsettings.json). Here’s how you can do it:
{
"Serilog": {
"Using": [ "Nandel.Extensions.Serilog.GoogleAgentTextFormatter" ],
"WriteTo": [
{
"Name": "Console",
"Args": {
"formatter": "Nandel.Extensions.Serilog.GoogleAgentTextFormatter, Nandel.Extensions.Serilog.GoogleAgentTextFormatter"
}
}
]
}
}
Summary
The GoogleAgentTextFormatter is designed to ensure that your application's log output is formatted in a way that is compatible with GCP's logging services. By using this formatter, you can easily integrate your application logs with Google Cloud Platform monitoring solutions, allowing for better observability and management of your cloud applications.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- Serilog (>= 4.2.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0-alpha.2 | 474 | 3/23/2025 |
| 1.0.0-alpha.1 | 285 | 3/23/2025 |
| 1.0.0-alpha.0 | 173 | 3/23/2025 |