Giter Club home page Giter Club logo

watchdog's Introduction

WatchDog Logo

WatchDog

Introduction

WatchDog is a Realtime HTTP (Request & Response) and Exception logger and viewer for ASP.Net Core Web Apps and APIs. It allows developers log and view http requests made to their web application and also exception caught during runtime in their web applications in Realtime. It leverages on LiteDb a Serverless MongoDB-like database with no configuration and SignalR for real-time monitoring.

Request & Response Viewer

General Features

  • RealTime HTTP Request and Response Logger
  • RealTime Exception Logger
  • 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

  • Support for External Databases (local & remote)
    • Support for MSSQL(SQL Server), MySQL and PostgreSQL Databases

Fixes

  • Fixed Middleware order
  • Fixed Index pages not showing on MVC Apps

Installation

Install via .NET CLI

dotnet add package WatchDog.NET --version 1.2.0

Install via Package Manager

Install-Package WatchDog.NET --version 1.2.0

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.

services.AddWatchDogServices(opt => 
{ 
   opt.IsAutoClear = true; 
});

NOTE When IsAutoClear = true Default 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) Optional

Add Database Connection String and Choose SqlDriver Option

services.AddWatchDogServices(opt => 
{
   opt.IsAutoClear = false; 
   opt.SetExternalDbConnString = "Server=localhost;Database=testDb;User Id=postgres;Password=root;"; 
   opt.SqlDriverOption = WatchDogSqlDriverEnum.PostgreSql; 
});

Add WatchDog middleware in the HTTP request pipeline in Startup.cs under Configure()

Login page sample

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 projects startup or program class contains app.UseMvc() or app.UseRouting() then app.UseWatchDog() should come after Important If your projects startup or program class contains app.UseEndpoints() then app.UseWatchDog() should come before Important

Request and Response Sample Details

Add list of routes you want to ignore by the logger: Optional

List of routes, paths or specific strings to be ignored should be a comma separated string like below.

app.UseWatchDog(opt => 
{ 
   opt.WatchPageUsername = "admin"; 
   opt.WatchPagePassword = "Qwerty@123"; 
   opt.Blacklist = "Test/testPost, weatherforecast";
 });

Add WatchDog Exception Logger Optional

This is used to log in-app exceptions that occur during a particular HTTP request.

Exception Sample Details

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"; 
   opt.Blacklist = "Test/testPost, weatherforecast";
 });

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

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

Kelechi Onyekwere - Github Twitter

Israel Ulelu - Github Twitter

watchdog's People

Contributors

khelechy avatar izypro avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.