Skip to content
This repository was archived by the owner on Dec 13, 2018. It is now read-only.
This repository was archived by the owner on Dec 13, 2018. It is now read-only.

Console logger adds considerable latency to requests #515

@mikeharder

Description

@mikeharder

The console logger adds considerable latency to requests. Here's a comparsion of the average and maximum latency with no logging, serilog to a file, and console logging:

Metric No Logging Serilog to File Console Logging
Average (ms) 6.46 6.79 11.19
Max (ms) 7.08 8.45 67.63

https://github.com/mikeharder/AspNetLatency

A few options were discussed to improve console logging performance:

  1. Don't block the request waiting for calls to Console.WriteLine() (or setting console colors). Queue writes to something faster like ConcurrentQueue, and use a background thread to remove from queue and call Console.WriteLine(). One downside is that log writes may appear out-of-order with respect to direct Console.WriteLine() calls. Another downside is the server process may end before all logs have been flushed from the queue.

  2. Still write to the console synchronously during the request, but avoid expensive operations like setting colors. Could be an option on the existing console logger, or a new FastConsoleLogger.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions