/// <summary> /// Close the writer object /// </summary> public override void Close() { if (_writer == null) { return; } try { if (!_doneHeader) { _writer.WriteLine(GetFormatter().GetHead()); } _writer.WriteLine(GetFormatter().GetTail()); } catch { } Flush(); try { _writer.Close(); _file.Close(); } catch { } _writer = null; _file = null; s_logFile = null; _lastFileDate = null; }
/// <summary> /// Initilize log file /// </summary> /// <param name="isClient"> client file (always set true)</param> /// <param name="Path"> file path </param> public static void Initialize(bool isClient, String Path) { //if (_lastDate == null || !Utility.Util.IsEqual(_lastDate.Value.Date, DateTime.Now.Date)) //Set Now Date //{ // _lastDate = DateTime.Now.Date; //} //else //{ // //return if Last and current date is same // do not init log file // return; //} if (_handlers != null) { return; //already initilize } //create handler list //try //{ // Logger rootLogger = Logger.GetLogger(""); // Handler[] handlers = rootLogger.GetHandlers(); // for (int i = 0; i < handlers.Length; i++) // { // if (!_handlers.Contains(handlers[i])) // _handlers.Add(handlers[i]); // } //} //catch //{ //} //check loggers // if (VLogErrorBuffer.Get(false) == null) // AddHandler(VLogErrorBuffer.Get(true)); if (Path.Contains("*")) { Path = Path.Replace("*", "Star"); } _handlers = new List <Handler>(); VLogFile fh = VLogFile.Get(false, Path, isClient); if (fh == null) { fh = VLogFile.Get(true, Path, isClient); } AddHandler(fh); SetFormatter(VLogFormatter.Get()); SetFilter(VLogFilter.Get()); }
/// <summary> /// Get File Logger /// </summary> /// <param name="create">create if not exists</param> /// <param name="viennaHome">vienna home</param> /// <param name="isClient">client or not</param> /// <returns>File Logger</returns> public static VLogFile Get(bool create, String viennaHome, bool isClient) { //if (s_logFile!=null && !s_logFile._viennaHome.Equals(viennaHome)) //{ // s_logFile = null; // create = true; //} //if (s_logFile == null && create) s_logFile = new VLogFile(viennaHome, true, isClient); return(s_logFile); } // get
/// <summary> /// Initializes /// use Initialize(bool,string,bool) /// </summary> /// <param name="isClient">if client</param> public static void Initialize(bool isClient) { if (_handlers != null) { return; } //create handler list _handlers = new List <Handler>(); try { //Logger rootLogger = Logger.GetLogger(""); //Handler[] handlers = rootLogger.GetHandlers(); //for (int i = 0; i < handlers.Length; i++) //{ // if (!_handlers.Contains(handlers[i])) // _handlers.Add(handlers[i]); //} } catch { } //check loggers //if (VLogErrorBuffer.Get(false) == null) // AddHandler(VLogErrorBuffer.Get(true)); VLogFile fh = VLogFile.Get(false, null, isClient); if (fh == null && !isClient) { fh = VLogFile.Get(true, null, isClient); AddHandler(fh); } SetFormatter(VLogFormatter.Get()); SetFilter(VLogFilter.Get()); }