public static string LogInfo(string message, string dir = "Common", string idLog = "") { if (string.IsNullOrEmpty(idLog)) { idLog = Config.MakeRefId(); } if (string.IsNullOrEmpty(dir)) { dir = "Common"; } message = idLog + " - " + message; if (!string.IsNullOrEmpty(dir)) { FileTarget target = new FileTarget(); target.Layout = "${longdate} ${message}"; // ${logger} target.FileName = @"C:/_LOG/" + dir + "/${date:format=yyyyMMdd}_log.txt"; target.ArchiveFileName = "${basedir}/archives/${date:format=yyyyMMdd}_log_bak.txt"; target.ArchiveAboveSize = 1024 * 1024 * 2047; // archive files greater than 10 KB target.Name = "Debug"; target.ConcurrentWrites = true; target.ConcurrentWrites = true; SimpleConfigurator.ConfigureForTargetLogging(target, LogLevel.Debug); Log.Factory.Configuration.AddTarget(dir, target); //Log.Error(":\t" + GetCalleeString() + Environment.NewLine + "\t" + message); Log.Error(":\t" + message); } else { LogMessage(message); } return(idLog); }
public static void LogMessage(string message, string dir, string idLog = "") { if (string.IsNullOrEmpty(idLog)) { idLog = Config.MakeRefId(); } message = idLog + " - " + message; if (!string.IsNullOrEmpty(dir)) { FileTarget target = new FileTarget(); //target.Layout = "${longdate} ${logger} ${message}"; target.Layout = "${longdate} ${message}"; target.FileName = "${basedir}/_LOG/" + dir + "/${date:format=yyyyMMdd}_Log.txt"; target.ArchiveFileName = "${basedir}/archives/${date:format=yyyyMMdd}_Log_bak.txt"; target.ArchiveAboveSize = 1024 * 1024 * 2046; // archive files greater than 2G target.Name = "Debug"; target.ConcurrentWrites = true; target.ConcurrentWrites = true; SimpleConfigurator.ConfigureForTargetLogging(target, LogLevel.Debug); Log.Factory.Configuration.AddTarget(dir, target); Log.Error(":\t" + message); } else { LogMessage(message); } }