IzyPro/WatchDog
소개
WatchDog는 ASP.Net Core 웹 앱과 API를 위한 실시간 메시지, 이벤트, HTTP(요청 및 응답), 예외 로거 및 뷰어입니다. 개발자는 웹 애플리케이션의 메시지와 이벤트, 웹 애플리케이션에서 발생한 HTTP 요청, 실행 중 포착된 예외를 모두 실시간으로 기록하고 확인할 수 있습니다.
웹 및 앱 개발What you can do
- RealTime HTTP Request, Response, and Exception Logger
- In-code message and event logging
- User Friendly Logger Views
- Search Option for HTTP and Exception Logs
측정된 스타 증가
- in 24h
- 0
- in 7 days
- 0
- in 15 days
- 0
- in 1 month
- 0
서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.
README.md
OriginalWatchDog
Introduction
WatchDog is a Realtime Message, Event, HTTP (Request & Response) and Exception logger and viewer for ASP.Net Core Web Apps and APIs. It allows developers log and view messages, events, http requests made to their web application and also exception caught during runtime in their web applications, all in Realtime.
It leverages SignalR for real-time monitoring and LiteDb a Serverless MongoDB-like database with no configuration with the option of using your external databases (MSSQL, MySQl, Postgres, MongoDB).
General Features
- RealTime HTTP Request, Response, and Exception Logger
- In-code message and event logging
- User Friendly Logger Views
- Search Option for HTTP and Exception Logs
- Filtering Option for HTTP Logs using HTTP Methods and StatusCode
- Logger View Authentication
- Auto Clear Logs Option
What's New
- Package upgrades for vulnerability patches
Breaking Changes
- SqlDriverOption is now DbDriverOption (>= v1.4.0)
Support
- .NET Core 3.1 and newer
Installation
Install via .NET CLI
dotnet add package WatchDog.NET --version 1.4.12
Install via Package Manager
Install-Package WatchDog.NET --version 1.4.12
Usage
To enable WatchDog to listen for requests, use the WatchDog middleware provided by WatchDog.
Add WatchDog Namespace in Startup.cs
using WatchDog;
Register WatchDog service in Startup.cs under ConfigureService()
services.AddWatchDogServices();
Setup AutoClear Logs Optional
This clears the logs after a specific duration.
NOTE When
IsAutoClear = trueDefault Schedule Time is set to Weekly, override the settings like below:
services.AddWatchDogServices(opt =>
{
opt.IsAutoClear = true;
opt.ClearTimeSchedule = WatchDogAutoClearScheduleEnum.Monthly;
});
Setup Logging to External Db (MSSQL, MySQL, PostgreSQL & MongoDb) Optional
Add Database Connection String and Choose DbDriver Option
services.AddWatchDogServices(opt =>
{
opt.IsAutoClear = true;
opt.SetExternalDbConnString = "Server=localhost;Database=testDb;User Id=postgres;Password=root;";
opt.DbDriverOption = WatchDogDbDriverEnum.PostgreSql;
});
Add WatchDog middleware in the HTTP request pipeline in Startup.cs under Configure()
NOTE Add Authentication option like below:
Important
This authentication information (Username and Password) will be used to access the log viewer.
app.UseWatchDog(opt =>
{
opt.WatchPageUsername = "admin";
opt.WatchPagePassword = "Qwerty@123";
});
NOTE If your project uses authentication, then
app.UseWatchDog();should come after app.UseRouting(), app.UseAuthentication(), app.UseAuthorization(), in that order
Optional Configurations: Optional
- Blacklist: List of routes, paths or endpoints to be ignored (should be a comma separated string like below).
- Serializer: If not default, specify the type of global json serializer/converter used.
- CorsPolicy: Policy Name if project uses CORS.
- UseOutputCache: If your application uses ASP.NET Output Cache. This feature is only available for .NET8 and above.
- UseRegexForBlacklisting: Enables the use of Regex to blacklist request routes, paths or endpoints.
app.UseWatchDog(opt =>
{
opt.WatchPageUsername = "admin";
opt.WatchPagePassword = "Qwerty@123";
//Optional
opt.Blacklist = "Test/testPost, api/auth/login"; //Prevent logging for specified endpoints
opt.Serializer = WatchDogSerializerEnum.Newtonsoft; //If your project use a global json converter
opt.CorsPolicy = "MyCorsPolicy";
opt.UseOutputCache = true;
opt.UseRegexForBlacklisting = true;
});
Add WatchDog Exception Logger Optional
This is used to log in-app exceptions that occur during a particular HTTP request.
NOTE Add Exception Logger before the main WatchDog Middleware, preferably at the top of the middleware hierarchy so as to catch possible early exceptions.
app.UseWatchDogExceptionLogger();
...
app.UseWatchDog(opt =>
{
opt.WatchPageUsername = "admin";
opt.WatchPagePassword = "Qwerty@123";
...
});
Log Messages/Events
WatchLogger.Log("...Test Log...");
WatchLogger.LogWarning(JsonConvert.Serialize(model));
WatchLogger.LogError(res.Content, eventId: reference);
Sink Logs from ILogger
You can also sink logs from the .NET ILogger into WatchDog
For .NET 6 and above
builder.Logging.AddWatchDogLogger();
For .NET Core 3.1, configure logging and add .AddWatchDogLogger() to the CreateHostBuilder method of the Program.cs class
Host.CreateDefaultBuilder(args)
.ConfigureLogging( logging =>
{
logging.AddWatchDogLogger();
})
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
});
View Logs and Exception
Start your server and head to /watchdog to view the logs.
Example: https://myserver.com/watchdog or https://localhost:[your-port]/watchdog
Still confused? Check out the implementation in the WatchDogCompleteTestAPI folder or the .NET 6 implementation in the WatchDogCompleteApiNet6 folder.
Contribution
Feel like something is missing? Fork the repo and send a PR.
Encountered a bug? Fork the repo and send a PR.
Alternatively, open an issue and we'll get to it as soon as we can.
Credit
관련 프로젝트 살펴보기
불러오는 중…





