{"id":31679208,"url":"https://github.com/rkdcoder/httpgossip","last_synced_at":"2026-01-20T17:27:14.138Z","repository":{"id":312304623,"uuid":"1047071524","full_name":"rkdcoder/HttpGossip","owner":"rkdcoder","description":"HttpGossip é um middleware de logging HTTP assíncrono para ASP.NET Core (.NET 8+). Ele captura requisições e respostas completas, armazena em uma fila em memória e persiste de forma fire-and-forget via Dapper em SQL Server, PostgreSQL, MySQL ou SQLite — sem nunca bloquear o fluxo da sua API.","archived":false,"fork":false,"pushed_at":"2025-09-29T11:07:53.000Z","size":1355,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-09-29T13:11:05.076Z","etag":null,"topics":["http-request-logger","middleware","nuget"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rkdcoder.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-08-29T17:35:04.000Z","updated_at":"2025-09-29T11:07:57.000Z","dependencies_parsed_at":"2025-08-29T19:42:16.839Z","dependency_job_id":"ee680664-58b9-4ad7-b5c7-94655b27fa77","html_url":"https://github.com/rkdcoder/HttpGossip","commit_stats":null,"previous_names":["rkdcoder/httpgossip","rkdcoder/http-gossip"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/rkdcoder/HttpGossip","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rkdcoder%2FHttpGossip","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rkdcoder%2FHttpGossip/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rkdcoder%2FHttpGossip/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rkdcoder%2FHttpGossip/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rkdcoder","download_url":"https://codeload.github.com/rkdcoder/HttpGossip/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rkdcoder%2FHttpGossip/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278903011,"owners_count":26065786,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-08T02:00:06.501Z","response_time":56,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["http-request-logger","middleware","nuget"],"created_at":"2025-10-08T06:46:04.063Z","updated_at":"2025-10-08T06:46:05.341Z","avatar_url":"https://github.com/rkdcoder.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# HttpGossip – Fire-and-Forget HTTP Logging for ASP.NET Core (.NET 8+)\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://raw.githubusercontent.com/rkdcoder/HttpGossip/main/src/HttpGossip/Media/icon.png\" width=\"128\" alt=\"HttpGossip logo\" /\u003e\n\u003c/p\u003e\n\n[![NuGet](https://img.shields.io/nuget/v/HttpGossip.svg)](https://www.nuget.org/packages/HttpGossip)\n[![Build \u0026 Publish](https://github.com/rkdcoder/HttpGossip/actions/workflows/main.yml/badge.svg)](https://github.com/rkdcoder/HttpGossip/actions/workflows/main.yml)\n[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)\n\n\n**HttpGossip** is a lightweight, production‑ready HTTP logging middleware for ASP.NET Core. It captures request/response metadata and bodies, pushes logs into an in‑memory **bounded queue**, and persists them asynchronously via **Dapper** to **SQL Server**, **PostgreSQL**, **MySQL**, or **SQLite**.\n\n* **Fire‑and‑forget**: logging never blocks requests.\n* **Safe by design**: if persistence fails, your API is **never penalized** (warnings only).\n* **Single‑project library**: easy to drop in, easy to ship.\n* **Optional schema helper**: create the table with an elevated connection when needed.\n\n---\n\n## Quickstart\n\n### 1) Register and use the middleware\n\n```csharp\nusing HttpGossip;\n\nvar builder = WebApplication.CreateBuilder(args);\n\nbuilder.Services.AddHttpGossip(options =\u003e\n{\n    options.DatabaseName       = \"SqlServer\"; // \"SqlServer\" | \"PostgreSQL\" | \"MySql\" | \"SQLite\"\n    options.ConnectionString   = builder.Configuration.GetConnectionString(\"Default\")!;\n    options.TableQualifiedName = \"logs.WSLOG_IdentityAndAccess\"; // schema.table (or [schema].[table] for SQL Server)\n\n    // Optional (no defaults applied if omitted)\n    // options.SensitivePaths = new[] { \"/login\", \"/password\", \"/token\" };\n    // options.BypassPaths    = new[] { \"/swagger\", \".js\", \".css\", \"/health\" };\n\n    // Only these have safe defaults (configurable)\n    options.QueueCapacity = 10_000;       // default 10_000\n    options.MaxBodyBytes  = 64 * 1024;    // default 64 KB\n});\n\nvar app = builder.Build();\n\napp.UseHttpGossip(); // adds the middleware\n\napp.MapControllers();\napp.Run();\n```\n\n\u003e **Always-on body capture**: Request and response bodies are captured by default; no option is exposed to disable them here. Bodies are truncated to `MaxBodyBytes` and marked with `[TRUNCATED]` when the limit is reached.\n\n### 2) Bind from configuration (optional)\n\nIf you prefer configuration binding, you can bind a section into the same `HttpGossipOptions` shape and pass it to `AddHttpGossip`.\n\n```json\n{\n  \"ConnectionStrings\": {\n    \"Default\": \"Server=.;Database=YourDb;User Id=usr;Password=pwd;TrustServerCertificate=True;\"\n  },\n  \"HttpGossip\": {\n    \"DatabaseName\": \"SqlServer\",\n    \"ConnectionString\": \"Server=.;Database=YourDb;User Id=usr;Password=pwd;TrustServerCertificate=True;\",\n    \"TableQualifiedName\": \"logs.WSLOG_IdentityAndAccess\",\n    \"QueueCapacity\": 10000,\n    \"MaxBodyBytes\": 65536,\n    \"SensitivePaths\": [\"/login\", \"/password\", \"/token\"],\n    \"BypassPaths\": [\"/swagger\", \".js\", \".css\", \"/health\"]\n  }\n}\n```\n\n```csharp\nvar section = builder.Configuration.GetSection(\"HttpGossip\");\nbuilder.Services.AddHttpGossip(section.Bind);\n```\n\n---\n\n## Optional: create the table with an elevated connection\n\nUse the schema helper **outside** the request pipeline (e.g., at startup, a one‑off admin endpoint, or a migration job). This allows you to use a different connection string with higher privileges.\n\n```csharp\nusing HttpGossip;\n\nawait HttpGossipSchema.EnsureLogTableAsync(new HttpGossipSchemaOptions\n{\n    DatabaseName       = \"SqlServer\", // or PostgreSQL/MySql/SQLite\n    ConnectionString   = builder.Configuration.GetConnectionString(\"AdminDdl\")!,\n    TableQualifiedName = \"logs.WSLOG_IdentityAndAccess\"\n});\n```\n\n* Idempotent: creates schema/table **if missing**.\n* Provider‑aware DDL for SQL Server, PostgreSQL, MySQL, and SQLite.\n\n---\n\n## What gets logged\n\n* **Timing**: `LogRequestStart` / `LogRequestEnd` (local time), `LogElapsedSeconds`\n* **Outcome**: `LogIsSuccess`, `LogStatusCode`, `LogException`\n* **Request**: `LogMethod`, `LogPath`, `LogQueryString`, `LogRouteValues`, `LogContentLength`\n* **Redaction**: `LogAuthorization` keeps **only the scheme** (e.g., `Bearer`)\n* **Headers \u0026 Client**: `LogHeaders`, `LogCookies`, `LogReferer`, `LogUserAgent`, `LogSecChUa*`\n* **Host \u0026 Network**: `LogHost`, `LogLocalIp`/`Port`, `LogRemoteIp`/`Port`, `LogConnectionId`\n* **Bodies**: `LogRequestBody`, `LogResponseBody`, `LogResponseContentType` (bodies may be `[REDACTED]` for sensitive paths; they are truncated to `MaxBodyBytes`)\n\n\u003e **Sensitive paths** are redacted only if you configure `SensitivePaths`. If you omit it, **no redaction by path** is applied.\n\n---\n\n## Options\n\n**Required**\n\n* `DatabaseName` (string): `\"SqlServer\" | \"PostgreSQL\" | \"MySql\" | \"SQLite\"`\n* `ConnectionString` (string)\n* `TableQualifiedName` (string): e.g., `\"logs.WSLOG_IdentityAndAccess\"`\n\n**Optional** (no defaults applied if omitted)\n\n* `SensitivePaths` (`string[]?`): redact request/response bodies when the path contains any entry.\n* `BypassPaths` (`string[]?`): skip logging for matching paths (e.g., swagger, health, static files).\n\n**Defaults (safe \u0026 configurable)**\n\n* `QueueCapacity` (int, default **10,000**): bounded in‑memory queue; when full, new writes are **dropped** to avoid backpressure.\n* `MaxBodyBytes` (int, default **65,536**): max bytes captured for request/response bodies; appends `[TRUNCATED]` at the limit.\n\n\u003e Bodies are **always captured** in HttpGossip. Use `SensitivePaths` to redact and `BypassPaths` to skip endpoints entirely.\n\n---\n\n## Supported databases\n\n* **SQL Server** (Microsoft.Data.SqlClient + Dapper)\n* **PostgreSQL** (Npgsql + Dapper)\n* **MySQL** (MySqlConnector + Dapper)\n* **SQLite** (Microsoft.Data.Sqlite + Dapper)\n\n---\n\n## Example DDL (SQL Server)\n\n\u003e You can also rely on `HttpGossipSchema.EnsureLogTableAsync(...)` instead of hand‑writing DDL.\n\n```sql\nCREATE TABLE [logs].[WSLOG_IdentityAndAccess](\n    [Id] BIGINT IDENTITY(1,1) NOT NULL PRIMARY KEY,\n    [LogRequestId] NVARCHAR(4000) NULL,\n    [LogRequestStart] DATETIME2(7) NOT NULL,\n    [LogRequestEnd] DATETIME2(7) NULL,\n    [LogElapsedSeconds] FLOAT NULL,\n    [LogIsSuccess] BIT NULL,\n    [LogStatusCode] INT NULL,\n    [LogException] NVARCHAR(MAX) NULL,\n    [LogUserName] NVARCHAR(4000) NULL,\n    [LogLocale] NVARCHAR(4000) NULL,\n    [LogMethod] NVARCHAR(4000) NULL,\n    [LogIsHttps] BIT NULL,\n    [LogProtocol] NVARCHAR(4000) NULL,\n    [LogScheme] NVARCHAR(4000) NULL,\n    [LogPath] NVARCHAR(4000) NULL,\n    [LogQueryString] NVARCHAR(MAX) NULL,\n    [LogRouteValues] NVARCHAR(MAX) NULL,\n    [LogAuthorization] NVARCHAR(MAX) NULL,\n    [LogHeaders] NVARCHAR(MAX) NULL,\n    [LogCookies] NVARCHAR(MAX) NULL,\n    [LogReferer] NVARCHAR(4000) NULL,\n    [LogUserAgent] NVARCHAR(4000) NULL,\n    [LogSecChUa] NVARCHAR(4000) NULL,\n    [LogSecChUaMobile] NVARCHAR(4000) NULL,\n    [LogSecChUaPlatform] NVARCHAR(4000) NULL,\n    [LogAppName] NVARCHAR(100) NULL,\n    [LogHost] NVARCHAR(200) NULL,\n    [LogContentLength] BIGINT NULL,\n    [LogRequestBody] NVARCHAR(MAX) NULL,\n    [LogResponseBody] NVARCHAR(MAX) NULL,\n    [LogResponseContentType] NVARCHAR(4000) NULL,\n    [LogLocalIp] NVARCHAR(4000) NULL,\n    [LogLocalPort] INT NULL,\n    [LogRemoteIp] NVARCHAR(4000) NULL,\n    [LogRemotePort] INT NULL,\n    [LogConnectionId] NVARCHAR(4000) NULL\n);\n```\n\n---\n\n## Behavior \u0026 guarantees\n\n* **Non‑blocking**: requests do not wait for database I/O.\n* **Bounded queue**: protects your API from backpressure; full queue **drops** new items.\n* **Background persistence**: a `BackgroundService` reads from the queue and inserts via Dapper.\n* **Failure‑tolerant**: DB errors are logged as warnings; the request flow is unaffected.\n* **Local timestamps**: `DateTime.Now` is used for start/end to match local expectations.\n\n---\n\n## Install\n\n```bash\n# once published to NuGet\ndotnet add package HttpGossip\n```\n\n---\n\n## License\n\n**MIT**\n\n---\n\n## Links\n\n* Repository: [https://github.com/rkdcoder/httpgossip](https://github.com/rkdcoder/httpgossip)\n* NuGet: [https://www.nuget.org/packages/HttpGossip](https://www.nuget.org/packages/HttpGossip)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frkdcoder%2Fhttpgossip","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frkdcoder%2Fhttpgossip","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frkdcoder%2Fhttpgossip/lists"}