public interface ILogRepository { void Write(LogEntry entry); ListRead(DateTime from, DateTime to); List Read(string source); void Clear(); int Count(); }
public class ConsoleLogRepository : ILogRepository { public void Write(LogEntry entry) { Console.WriteLine("{0} [{1}] {2}: {3}", entry.Timestamp, entry.Severity, entry.Source, entry.Message); } // Other ILogRepository methods are not implemented }This example shows a simple implementation of the ILogRepository interface that writes log entries to the console output. The Write method formats and prints the log entry using the Console.WriteLine method. The ILogRepository interface is typically part of a logging package library that provides various logging sinks, formatters, filters, and configuration options. Some popular logging package libraries for C# include log4net, NLog, Serilog, and Microsoft.Extensions.Logging. These package libraries offer rich and flexible logging frameworks that can be customized to meet the specific logging needs of different types of applications.