static public bool InitLog(LogInfo Info, string PrefileName) { LogConfig Config = new LogConfig(Info); Config.PreFileName = PrefileName; Log.Init(Config); return true; }
static public void InitInstance(LogConfig Config) { try { if (Config == null) Config = new LogConfig(); string FileDir = Directory.GetCurrentDirectory() + Config.LogFolder; string BackDir = Directory.GetCurrentDirectory() + Config.LogFolder + "/Backup"; try { Directory.CreateDirectory(FileDir); Directory.CreateDirectory(BackDir); } catch (Exception) { } FileDir += "/" + Config.PreFileName + Config.FileName; BackDir += "/" + Config.PreFileName + "." + DateTime.Now.Hour + "h." + DateTime.Now.Minute + "m." + DateTime.Now.Second + "s" + Config.FileName; if (DumpFile == null) { DumpFile = new FileInfo(FileDir); if (DumpFile.Exists) DumpFile.MoveTo(BackDir); DumpFile = new FileInfo(FileDir); if (FSDump != null) FSDump.Close(); FSDump = DumpFile.Create(); } if (Config != null) _config = Config; } catch (Exception) { Console.WriteLine("Log : Log file already in use."); if (Config != null) Config.Info.Dump = false; } }
static public bool InitLog(string LogConf, string PrefileName) { try { LogConfig Conf = new LogConfig(0); Conf.PreFileName = PrefileName; if (LogConf.Length > 0) Conf.LoadInfoFromFile(LogConf); Log.Init(Conf); } catch (Exception e) { Log.Error("InitLog", "Error : " + e.ToString()); return false; } Log.Notice("InitLog", "Logger initialized"); return true; }
public static bool InitLog(string LogConf, string PrefileName) { try { LogConfig Conf = new LogConfig(0); Conf.PreFileName = PrefileName; if (LogConf.Length > 0) { Conf.LoadInfoFromFile(LogConf); } Init(Conf); } catch (Exception e) { Error("InitLog", "Error : " + e); return(false); } Notice("InitLog", "Logger initialized"); return(true); }
public static void InitInstance(LogConfig Config) { try { if (Config == null) { Config = new LogConfig(); } string FileDir = Directory.GetCurrentDirectory() + Config.LogFolder; string BackDir = Directory.GetCurrentDirectory() + Config.LogFolder + "/Backup"; try { Directory.CreateDirectory(FileDir); Directory.CreateDirectory(BackDir); } catch (Exception) { } FileDir += "/" + Config.PreFileName + Config.FileName; BackDir += "/" + Config.PreFileName + "." + DateTime.UtcNow.Hour + "h." + DateTime.UtcNow.Minute + "m." + DateTime.UtcNow.Second + "s" + Config.FileName; if (DumpFile == null) { DumpFile = new FileInfo(FileDir); if (DumpFile.Exists) { DumpFile.MoveTo(BackDir); } DumpFile = new FileInfo(FileDir); if (FSDump != null) { FSDump.Close(); } FSDump = DumpFile.Create(); } if (Config != null) { _config = Config; } } catch (Exception) { Console.WriteLine("Log : Log file already in use."); if (Config != null) { Config.Info.Dump = false; } } _thread = new Thread(threadStart); _thread.IsBackground = true; // Detach the thread so it won't block exit _thread.Priority = ThreadPriority.BelowNormal; _thread.Start(); }
public static void Init(LogConfig Config) { InitInstance(Config); }