.net - How can i change the output format of TextWriterTraceListener? -
The default implementation shows the output as '::', now I do not want this format, I want to cut sourcename And eventid because it is completely useless for me. Is there any such easy way that I can fulfill?
My current solution is to get the textwriter from the trace listener and override the track event method. To make a copy of the default implementation, reflect and delete only the author header function call.
You can create a class derived from a text worker trace listener and override TraceEvent to change the output format. Are there. It would be better to override all traceoin methods. For example (string message) {base.Write (String.Format ("[[0] (text)"}]: {1} ", DateTime.Now, message))}} Public override zero WriteLine (string message) {Base.WriteLine (String.Format ("[{0}]: {1}", date time.Now, message));} Override public trace events (Trace Avent cache event cache, string source, trace event type event Type, IND, string message) {//base.TraceEvent (EventCache, Source, EventType, ID, Message); If (String.IsNullOrEmpty (message)) Return; WriteLine (String.Format ("{0}: { 1}: {2}: {3} ", s Replace ("\ n", string.Empty)));}}
Comments
Post a Comment