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 LogsDir, string fileName) { try { LogConfig Conf = new LogConfig(0); Conf.FileName = fileName; Conf.LogFolder = LogsDir; 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 void InitInstance(LogConfig Config) { try { if (Config == null) Config = new LogConfig(); if (!Config.LogFolder.StartsWith("/")) Config.LogFolder = "/" + Config.LogFolder; string FileDir = Directory.GetCurrentDirectory() + Config.LogFolder; string BackDir = Directory.GetCurrentDirectory() + Config.LogFolder + "/Backup"; try { Directory.CreateDirectory(FileDir); Directory.CreateDirectory(BackDir); } catch (Exception) { } FileDir += "/" + Config.FileName; BackDir += "/" + Config.FileName + "." + DateTime.Now.Hour + "h." + DateTime.Now.Minute + "m." + DateTime.Now.Second + "s"; 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) { lock (Console.Out) Console.WriteLine("Log : Log file already in use."); if (Config != null) Config.Info.Dump = false; } }
public static void Init(LogConfig Config) { InitInstance(Config); }
static public void Init(LogConfig Config) { InitInstance(Config); }
static public void InitInstance(LogConfig Config) { try { if (Config == null) { Config = new LogConfig(); } if (!Config.LogFolder.StartsWith("/")) { Config.LogFolder = "/" + Config.LogFolder; } string FileDir = Directory.GetCurrentDirectory() + Config.LogFolder; string BackDir = Directory.GetCurrentDirectory() + Config.LogFolder + "/Backup"; try { Directory.CreateDirectory(FileDir); Directory.CreateDirectory(BackDir); } catch (Exception) { } FileDir += "/" + Config.FileName; BackDir += "/" + Config.FileName + "." + DateTime.Now.Hour + "h." + DateTime.Now.Minute + "m." + DateTime.Now.Second + "s"; 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) { lock (Console.Out) Console.WriteLine("Log : Log file already in use."); if (Config != null) { Config.Info.Dump = false; } } }