Skip to content
master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
src
 
 
 
 
 
 
 
 

KissLog.net

Latest version Downloads

KissLog represents a powerful logging and monitoring solution for .NET applications.

Some of the main features of KissLog are:

  • Automatically captures and logs all the exceptions

  • Monitors all the HTTP traffic

  • Lightweight, powerful SDK

  • Centralized logging using kisslog.net or KissLog on-premises integration

Check the documentation for a complete list of features.

KissLog.net centralized logging

Framework support

Why KissLog?

KissLog is a logging framework which is focused primarily on HTTP behaviour.

For each HTTP request, KissLog automatically captures all the available properties, including: User Agent, Request Headers, Form Data, Request Body, SessionId, Response Headers, Status Code, Response Body.

Log messages are grouped per each unique HTTP request, making it easy to follow the execution details.

Basic usage

using KissLog;

public class HomeController : Controller
{
    private readonly ILogger _logger;
    public HomeController()
    {
        _logger = Logger.Factory.Get();
    }

    public IActionResult Index()
    {
        _logger.Debug("Hello World!");

        return View();
    }
}

Setup

Logs output

KissLog saves the logs to multiple output locations by using log listeners.

Log listeners are registered at application startup using the KissLogConfiguration.Listeners container.

Check the documentation for more logs output examples.

namespace MyApplication
{
    public class MvcApplication : System.Web.HttpApplication
    {
        // [...]

        private void RegisterKissLogListeners()
        {
            // register KissLog.net cloud listener
            KissLogConfiguration.Listeners.Add(new RequestLogsApiListener(new Application("d625d5c8-ef47-4cd5-bf2d-6b0a1fa7fda4", "39bb675d-5c13-4bd8-9b5a-1d368da020a2"))
            {
                ApiUrl = "https://api.kisslog.net"
            });
			
            // register NLog listener
            KissLogConfiguration.Listeners.Add(new NLogTargetListener());
            
            // register MongoDB listener
            KissLogConfiguration.Listeners.Add(new MongoDbListener());
        }
    }
}

Configuration

Logging behavior can be customized by using KissLogConfiguration.Options container.

Complete list of configuration options can be found on the documentation page.

protected void Application_Start()
{
    KissLogConfiguration.Options
        .JsonSerializerSettings.Converters.Add(new StringEnumConverter());

    KissLogConfiguration.Options
        .ShouldLogResponseBody((listener, logArgs, defaultValue) =>
        {
            int responseStatusCode = (int)logArgs.WebProperties.Response.HttpStatusCode;
            return responseStatusCode >= 400;
        });

    KissLogConfiguration.Options
        .AppendExceptionDetails((Exception ex) =>
        {
            // log EntityFramework validation errors
            if (ex is DbEntityValidationException dbException)
            {
                StringBuilder sb = new StringBuilder();
                sb.AppendLine("DbEntityValidationException:");

                foreach (var error in dbException.EntityValidationErrors.SelectMany(p => p.ValidationErrors))
                {
                    string message = string.Format("Field: {0}, Error: {1}", error.PropertyName, error.ErrorMessage);
                    sb.AppendLine(message);
                }

                return sb.ToString();
            }

            return null;
        });
}

Samples

Check the code samples for more examples of using KissLog.

Feedback

Please use the issues section to report bugs, suggestions and general feedback.

Contributing

All contributions are very welcomed: code, documentation, samples, bug reports, feature requests.

License

Apache-2.0

About

KissLog represents a powerful logging and monitoring solution for .NET applications

Topics

Resources

License

Releases

No releases published

Packages

No packages published

Languages