//---------------------------------------------------------------------- /// <summary> /// Dispose of resources. /// </summary> /// <param name="disposing"></param> protected override void Dispose(bool disposing) { TTrace.Flush(); if (disposing) { // Free state-managed objects. } base.Dispose(disposing); }
//---------------------------------------------------------------------- /// <summary> /// Writes the logging event to the TraceTool system. /// </summary> /// <param name="loggingEvent">The event to log.</param> protected override void Append(LoggingEvent loggingEvent) { try { // if null then first append. if (this.log4WinTrace == null) { if (this.winTraceId != null || this.winTraceTitle != null) { this.log4WinTrace = new WinTrace(this.winTraceId, this.winTraceTitle); if (this.Layout != null) { this.log4WinTrace.SetMultiColumn(); } } else { // no wintrace specified if (this.Layout != null) { // Layout on main trace window. create a brother main wintrace this.log4WinTrace = new WinTrace("_", "_"); this.log4WinTrace.SetMultiColumn(); // must be specified before setting titles } else { // no layout and no wintrace specified, use main wintrace this.log4WinTrace = TTrace.WinTrace; } } if (this.titleLayout != null && this.log4WinTrace != TTrace.WinTrace) { this.log4WinTrace.SetColumnsTitle(this.titleLayout); } if (this.logMode >= 0) { this.log4WinTrace.SetLogFile(this.logFileName, this.logMode); } } TraceNodeEx node = new TraceNodeEx(this.log4WinTrace.Debug); // if layout is used, fill only the leftMsg. if (this.Layout != null) { node.LeftMsg = RenderLoggingEvent(loggingEvent); // 1.2.0 beta8 and 1.2.9 beta //node.LeftMsg = this.Layout.Format (loggingEvent) ; // 1.2.0 b8 node.Time = ""; // blank time //$NON-NLS-1$ node.ThreadName = ""; // blank thread name //$NON-NLS-1$ } else { // no layout. Use tracetool columns node.LeftMsg = loggingEvent.LoggerName; node.RightMsg = loggingEvent.RenderedMessage; node.ThreadName = loggingEvent.ThreadName; node.Time = loggingEvent.TimeStamp.ToString("HH:mm:ss:fff"); // to do : change icon //int level = event.getLevel ().toInt () ; //String levelstr = event.getLevel ().toString () ; //node.iconIndex = 8 ; } // add the message object if not a primitive Object msg = loggingEvent.MessageObject; if (!(msg is string)) { node.AddValue(msg, this.sendPrivateObjectInfo, 3, "Trace Object"); } // add throwable info, if any // GetExceptionStrRep is Obsolete but is keept for previous version compatibility (1.2.0) // string strException = loggingEvent.GetExceptionString (); string strException = loggingEvent.GetExceptionStrRep(); if (strException != "") { TMemberNode localInfo = node.Members.Add("Exception informations"); string [] split = strException.Split(new Char[] { '\n', '\r' }); foreach (string s in split) { if (s.Trim() != "") { localInfo.Add(s); } } } // send Local information. if (this.sendLocationInfo) { TMemberNode localInfo = node.Members.Add("LocalInfo"); LocationInfo locInfo = loggingEvent.LocationInformation; localInfo.Add(locInfo.FileName, locInfo.MethodName, locInfo.LineNumber); } // finally send the node node.Send(); if (this.immediateFlush) { TTrace.Flush(); } } catch { // eat exception } }