Skip to content

Instantly share code, notes, and snippets.

@mkropat mkropat/NanoLog.cs

Last active Jul 5, 2016
What would you like to do?
C# logging nano-framework
public static class NanoLog
public static void Write(params object[] objs)
var logDir = System.Environment.GetEnvironmentVariable("SystemDrive") + @"\NanoLog";
if (!System.IO.Directory.Exists(logDir))
var logName = typeof(NanoLog).Assembly.GetName().Name + ".debug.log";
var logPath = System.IO.Path.Combine(logDir, logName);
var timestamp = System.DateTime.Now.ToString("HH:mm:ss.fff");
var asStrings = System.Array.ConvertAll(objs, System.Convert.ToString);
var line = $"{timestamp}: {string.Join(" - ", asStrings)}";
lock (_lock)
System.IO.File.AppendAllLines(logPath, new[] { line });
static object _lock = new object();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.