adams85 / filelogger

A lightweight yet feature-rich file logger implementation for the Microsoft.Extensions.Logging framework.
MIT License
147 stars 22 forks source link

Is Karambolo thread-safe? #23

Closed aleksvujic closed 1 year ago

aleksvujic commented 1 year ago

Is Karambolo file logging provider thread safe? What happens if two threads try to log a message at the same time?

adams85 commented 1 year ago

The logger is, of course, thread-safe. It uses System.Threading.Channels for implementing the producer/consumer pattern where a queue is maintained per each log file. Your log entries are written into the corresponding log file's queue (which is a thread-safe operation by design), and there is a consumer process (running on the thread pool) which reads these entries and writes them to the log file one after the other.

Does this answer your question?