Giter VIP home page Giter VIP logo

kisslog.sdk's Issues

Logging same InnerException throws an error

Logging two exceptions which have the same inner exception is throwing an error.

var logger = new Logger();

var innerEx = new Exception($"Inner exception: {Guid.NewGuid()}");
logger.Error(new Exception("Exception 1", innerEx));
logger.Error(new Exception("Exception 2", innerEx));
System.ArgumentException:
Item has already been added. Key in dictionary: 'KissLog-ExceptionLogged-2f21ed7d-09e6-47e2-b0ad-3b1172e79581'

MirrorStreamDecorator: Cannot access a closed Stream

In some scenarios, MemoryStreamDecorator is closed by .NET, but we are still trying to access it.

Thus, it throws ObjectDisposedException.

System.ObjectDisposedException: Cannot access a closed Stream.
   at System.IO.MemoryStream.Write(Byte[] buffer, Int32 offset, Int32 count)
   at KissLog.MirrorStreamDecorator.WriteAsync(Byte[] buffer, Int32 offset, Int32 count, CancellationToken cancellationToken) in C:\Catalin\KissLog-net\KissLog.Sdk\src\KissLog\MirrorStreamDecorator.cs:line 58
   at KissLog.MirrorStreamDecorator.WriteAsync(Byte[] buffer, Int32 offset, Int32 count, CancellationToken cancellationToken) in C:\Catalin\KissLog-net\KissLog.Sdk\src\KissLog\MirrorStreamDecorator.cs:line 58
   at Microsoft.AspNetCore.WebUtilities.HttpResponseStreamWriter.FlushInternalAsync(Boolean flushEncoder)
   at Microsoft.AspNetCore.WebUtilities.HttpResponseStreamWriter.WriteAsyncAwaited(String value)
   at Microsoft.AspNetCore.Mvc.ViewFeatures.Buffers.ViewBuffer.WriteToAsync(TextWriter writer, HtmlEncoder encoder)
   at Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderLayoutAsync(ViewContext context, ViewBufferTextWriter bodyWriter)
   at Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderLayoutAsync(ViewContext context, ViewBufferTextWriter 

Alert Notification by Email

Hi!

I'm not receiving the alert email notifications. I dont know if i'm missing something.

I configured the "Smtp" section in KissLog.config from Kisslog.Frontend with the correct infos and created a new alert with the "Email messages" turned on.

I know the alerts are being triggered, because i can see they in the "alerts" section of the application.

It can be a SSL configuration? Because i didn't find anything about how to configure it in documentation.

I'm using the free on-premise KissLog with AspNetCore SDK for a .Net 5.0 WebApi

Response Json and search for a SearchKey

Capturar

I'm having problems trying to visualize the json response, I'm using Kisslog on-premises , the installation tutorial was followed: https://kisslog.net/Docs/on-premises.installation-guide.html

Everything is working, but I can't perform filters or view the response, I'm interested in buying a license, but how do I solve this problem so that I can finish my tests?

Problem demo: https://mega.nz/file/8xY2EByL#mOyUIcc4KVd_YHxF9911VNwl5coNbTtDWp9KwvqMdcM

I'm using windows server with all software in its latest version today.

Implement Compiler Services on the Log Method

private void Log(LogLevel logLevel, string message, [CallerMemberName] string memberName = "", [CallerLineNumber] int lineNumber = 0, [CallerFilePath] string memberType = "")
{
_logger.Log(logLevel, message, memberName, lineNumber, memberType);
}

This way if the Calling Member or the line number is left blank it will be pre-filled by the compiler.

Logs not showing and some logs showing

As i observed the logs i noticed logs of few minutes ago was showing while those for less than 24Hours long period of time is not showing there were some other logs thats was missing
KissFewLogs

NLogTargetListener is not using the LogListenerParser

Registering the NLogTargetListener the following way

// NLog listener
config.Listeners.Add(new NLogTargetListener()
{
    ShouldWriteBeginRequestEvent = (KissLog.Web.HttpRequest httpRequest) => true,
    ShouldWriteFlushEvent = (KissLog.FlushArgs.FlushLogArgs args) => true,
    Parser = new MyCustomParser()
});

results in KissLog flushing every single message into NLog, ignoring the custom parser:

2019-10-14 16:29:09.4802 [GET /] 
2019-10-14 16:29:10.3469 AuthenticationHandler started. 
2019-10-14 16:29:10.3679 Swagger request. No authentication context established. 
2019-10-14 16:29:11.9607 [301 MovedPermanently][GET /] Duration: 2,246ms 
2019-10-14 16:29:12.0635 [GET /swagger/ui/index] 
2019-10-14 16:29:12.1023 AuthenticationHandler started. 
2019-10-14 16:29:12.1323 Swagger request. No authentication context established. 
2019-10-14 16:29:12.6863 [GET /swagger/ui/css/typography-css] 
2019-10-14 16:29:12.7531 AuthenticationHandler started. 
2019-10-14 16:29:12.7840 Swagger request. No authentication context established. 
2019-10-14 16:29:12.8040 [GET /swagger/ui/css/reset-css] 

Try-Catch-Finally handler

Create a try-catch-finally handler which will automatically log when a method starts and when it completes.

Usage

public async Task DeleteAsync()
{
    ILogger logger = Logger.Factory.Get();;

    await logger.TryCatchFinallyAsync("DeleteAlerts", async () =>
    {
        await DeleteAlertsAsync();
    });

    await logger.TryCatchFinallyAsync("DeleteRequestLogs", async () =>
    {
        await DeleteRequestLogsAsync();
    });
}

Output

[DEBUG] DeleteAlerts > start

@........ DeleteAlertsAsync() executing

[DEBUG] DeleteAlerts > complete



[DEBUG] DeleteRequestLogs > start

@........ DeleteRequestLogsAsync() executing

[ERROR] System.NullReferenceException: Object reference not set to an instance of an object.
[DEBUG] DeleteRequestLogs > complete

Could not load type 'Microsoft.AspNetCore.Http.Internal.BufferingHelper' .Net Core 3.0

Using Net Core 3.0 There is a new error with kisslog 2.4.0

System.TypeLoadException: Could not load type 'Microsoft.AspNetCore.Http.Internal.BufferingHelper' from assembly 'Microsoft.AspNetCore.Http, Version=3.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'.
   at KissLog.AspNetCore.WebRequestPropertiesFactory.ReadInputStream(HttpRequest request)
   at KissLog.AspNetCore.WebRequestPropertiesFactory.Create(HttpRequest request)
   at KissLog.AspNetCore.KissLogMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)

Friendly format *.xml files

Need to format the *.xml files similar as we do with *.json files.
Right now, the XML is not formatted and it is displayed as it is.

image

Allow configuration within UseKissLogMiddleWare

It would be cool to allow following to setup KissLog

app.UseKissLogMiddleware(builder =>
{
    builder.Listeners.Add(new KissLogApiListener(new Application(_conf["KissLog:OrganizationId"], _conf["KissLog:ApplicationId"])));
    builder.Options.ShouldLogResponseBody((listener, args, arg3) => args.WebRequestProperties.Response.HttpStatusCode >= HttpStatusCode.BadRequest);
});

For now I have the following workaround:

public static class IApplicationBuilderExtensions
{
    public class KissLogHelper
    {
        public Options Options => KissLogConfiguration.Options;
        public List<ILogListener> Listeners => KissLogConfiguration.Listeners;
    }

    public static IApplicationBuilder UseKissLogMiddleware(this IApplicationBuilder app,  Action<KissLogHelper> configure)
    {
        var builder = app.UseKissLogMiddleware();
        configure(new KissLogHelper());
        return builder;
    }
}

Get Environment Name for Logging

Is there a way to add the Environment Name to the File Formatter, I need to debug some environment related problem, but I need to see in the logs in which environment the app is running.

Dashboard does not list requests when the controller has the Authorize attribute.

I am implementing kisslog in an API that I am developing and I am having a problem that I cannot say if it is a bug or if it is a problem with my implementations.
The problem is that when a controller method uses the Authorize attribute, the physical log is generated but the request is not listed on the dashboard.

It's OK
image
image

It's not OK
image

Writing logs in background jobs - Task.Factory.StartNew

Logs are persisted, by default, at the end of the HTTP Request.

If we start a background job, the log messages will not be persisted, because the HTTP Request will have already been finished by that time.

Possible quick fix is to update the LocalTextFileListener to write the logs as soon as they are provided.

KissLogApiListener (cloud listener) do needs to be instructed manually to persist the logs.

Task.Factory.StartNew(async () => {
    List<Task> tasks = new List<Task>();

    foreach (var item in mails)
    {
        Task task = _emailsService.SendEmailAsync(EmailType.ApplicationCreated, item.Model, item.To, true);
        tasks.Add(task);
    }

    await Task.WhenAll(tasks);
});

kisslog sdk error UnauthorizedAccessException

Windows server 2022 and iis 10

image

KissLog.Exceptions.LogStringAsFileException: KissLog: Error when trying to log as file the string with length 498
---> System.UnauthorizedAccessException: Access to the path is denied.
at System.IO.Path.GetTempFileName()
at KissLog.TemporaryFile.GetTempFileName(String extension)
at KissLog.TemporaryFile..ctor(String extension)
at KissLog.TemporaryFile..ctor()
at KissLog.LoggerData.FilesContainer.LogAsFile(String contents, String fileName)
--- End of inner exception stack trace ---

Every log will contains this error

Using Kisslog in Custom DLL

I want to be able to run KissLog in a Specific DLL that maybe used in several projects, but want the DLL to have its own identity for logging purposes.

Generating data for the Users Tab

Hi folks, is there any documentation to generate data for Users Tab?

I'm coding in ASP NET CORE 3.0 + Identity + JWT. And my tab always display "There are no users captured for XXXXX".

I'm testing Kisslog in develop environment (https://localhost). Could this cause the problem?

Tks

"application/problem+json" Response Content-Type

https://github.com/KissLog-net/KissLog.Sdk/blob/1dfcfb013bd3a9ea831176b14430078ecd900c36/src/KissLog/Internal/InternalHelpers.cs#L16

Need to update the Response Content-Type with more values:

{
    "Content-Type": "application/problem+json; charset=utf-8"
}

We should allow for providing the values on KissLogConfiguration.Options

KissLogConfiguration.Options
        .SetLogResponseBodyContentTypes(() =>
        {
            return new string[] { "application/json", "application/problem+json" };
        });

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.