Sorry it's possibly a duplicate but in the other static interface they mention generics which I am not using.
I wanted a quick and simple logger for my app I though I could avoid a singleton using a static element. I would have like to keep the interface so that later I could change to another logging package. The interface being for me (I may be wrong here) a way to implement a "facade" feature.
I have the feeling I am overlooking something. A gentle push in the right direction would be greatly appreciated. (Hope it's a bit clearer)
public interface Ilogger
{
void Log(string data, out DateTime datetime, out string uid);
}
public class Logger : Ilogger
{
private static TraceSource AppTrace = new TraceSource("RD", SourceLevels.All);
static Logger ()
{
AppTrace.Listeners.Clear();
AppTrace.Listeners.Add(new DelimitedListTraceListener("RD.log"));
}
static void Log(string data, out DateTime datetime, out string uid)
{
datetime = DateTime.Now;
uid = Guid.NewGuid().ToString();
AppTrace.TraceInformation(datetime + ";" + uid + ";" + data);
}
}