![]() |
VOOZH | about |
dotnet add package WatchDog.NET --version 1.4.12
NuGet\Install-Package WatchDog.NET -Version 1.4.12
<PackageReference Include="WatchDog.NET" Version="1.4.12" />
<PackageVersion Include="WatchDog.NET" Version="1.4.12" />Directory.Packages.props
<PackageReference Include="WatchDog.NET" />Project file
paket add WatchDog.NET --version 1.4.12
#r "nuget: WatchDog.NET, 1.4.12"
#:package WatchDog.NET@1.4.12
#addin nuget:?package=WatchDog.NET&version=1.4.12Install as a Cake Addin
#tool nuget:?package=WatchDog.NET&version=1.4.12Install as a Cake Tool
👁 WatchDog
👁 Version
👁 Downloads
👁 MIT License
👁 WatchDog
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).
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
To enable WatchDog to listen for requests, use the WatchDog middleware provided by WatchDog.
Add WatchDog Namespace in Startup.cs
using WatchDog;
Startup.cs under ConfigureService()services.AddWatchDogServices();
OptionalThis 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;
});
OptionalAdd 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;
});
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
Optionalapp.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;
});
OptionalThis 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";
...
});
WatchLogger.Log("...Test Log...");
WatchLogger.LogWarning(JsonConvert.Serialize(model));
WatchLogger.LogError(res.Content, eventId: reference);
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>();
});
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.
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.
Kelechi Onyekwere - Github Twitter
<!--
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 net5.0 was computed. net5.0-windows net5.0-windows was computed. net6.0 net6.0 is compatible. net6.0-android net6.0-android was computed. net6.0-ios net6.0-ios was computed. net6.0-maccatalyst net6.0-maccatalyst was computed. net6.0-macos net6.0-macos was computed. net6.0-tvos net6.0-tvos was computed. net6.0-windows net6.0-windows was computed. net7.0 net7.0 was computed. net7.0-android net7.0-android was computed. net7.0-ios net7.0-ios was computed. net7.0-maccatalyst net7.0-maccatalyst was computed. net7.0-macos net7.0-macos was computed. net7.0-tvos net7.0-tvos was computed. net7.0-windows net7.0-windows was computed. net8.0 net8.0 is compatible. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
| .NET Core | netcoreapp3.1 netcoreapp3.1 is compatible. |
Showing the top 5 NuGet packages that depend on WatchDog.NET:
| Package | Downloads |
|---|---|
|
LC.Web.Base
LC.Web.Base |
|
|
Chaosage.Core.Setup
Chaosage开发平台API配置规范 |
|
|
JobPro.Configurations.Global
This nuget package contains all the configurations for micro service architecture |
|
|
PluginCore.Plugins.WatchDogPlugin
PluginCore Plugins: WatchDogPlugin |
|
|
Peak.Lib.Web
Package Description |
Showing the top 1 popular GitHub repositories that depend on WatchDog.NET:
| Repository | Stars |
|---|---|
|
Jinjinov/OpenHabitTracker
C# .NET 9 Blazor habit tracker application. Works on Web, Windows, Linux, Android, iOS and macOS.
|
| Version | Downloads | Last Updated |
|---|---|---|
| 1.4.12 | 36,104 | 12/21/2024 |
| 1.4.11 | 40,615 | 3/31/2024 |
| 1.4.10 | 42,994 | 5/19/2023 |
| 1.4.7 | 8,262 | 4/19/2023 |
| 1.4.6 | 27,429 | 2/16/2023 |
| 1.4.3 | 22,803 | 2/1/2023 |
| 1.4.2 | 5,760 | 1/18/2023 |
| 1.4.1 | 1,755 | 1/17/2023 |
| 1.4.0 | 3,393 | 1/16/2023 |
| 1.3.3 | 19,024 | 12/14/2022 |
| 1.3.3-rc | 1,678 | 11/7/2022 |
| 1.3.2 | 31,037 | 9/18/2022 |
| 1.3.1 | 7,676 | 8/9/2022 |
| 1.3.0 | 4,019 | 7/19/2022 |
| 1.2.1 | 6,907 | 6/7/2022 |
| 1.2.0 | 2,372 | 5/15/2022 |
- Package upgrades for vulnerability patches