ubeac / ubeac-api

Source of uBeac .NET Core packages
3 stars 2 forks source link

Cleanup & Fix Logging Issues #97

Closed ilhesam closed 2 years ago

ilhesam commented 2 years ago
The following packages must be installed to implement HTTP Logging: uBeac.Web.Logging uBeac.Web.Logging.MongoDB
Contains model, middleware and repository interface Contains repository implementation and options
πŸ”— uBeac.Web.Logging Dependencies: Package Name Use Case
uBeac.Common To using from IApplicationContext
πŸ”— uBeac.Web.Logging.MongoDB Dependencies: Package Name Use Case
uBeac.Web.Logging To implementing repository interface and accessing to model
uBeac.Repositories.MongoDB To prevent duplicate code in registering BSON serializers (Especially IApplicationContext bson serializer) NOTE: We can also have a package in Common called uBeac.MongoDB that includes BSON serializers, MongoDB configuration and context

❓ How do I implement?

Put this code inside Startup.cs:

// Adding MongoDB HTTP Logging Repository to IServiceCollection
builder.Services.AddMongoDbHttpLogging(builder.Configuration.GetInstance<MongoDbHttpLogOptions>("HttpLogging"));

// Adding HTTP Logging Middleware to IApplicationBuilder
app.UseHttpLoggingMiddleware();

And configure your http-logging.json:

{
  "HttpLogging": {
    "HttpLog2xxConnectionString": "mongodb://localhost:27017/uBeac-Identity-Template-Http-Logging",
    "HttpLog2xxCollectionName": "HttpLog-2xx",
    "HttpLog4xxConnectionString": "mongodb://localhost:27017/uBeac-Identity-Template-Http-Logging",
    "HttpLog4xxCollectionName": "HttpLog-4xx",
    "HttpLog5xxConnectionString": "mongodb://localhost:27017/uBeac-Identity-Template-Http-Logging",
    "HttpLog5xxCollectionName": "HttpLog-5xx"
  }
}
ilhesam commented 2 years ago
ilhesam commented 2 years ago
ilhesam commented 2 years ago
ilhesam commented 2 years ago
ilhesam commented 2 years ago
ilhesam commented 2 years ago
ilhesam commented 2 years ago
ilhesam commented 2 years ago
ilhesam commented 2 years ago