Trace.TraceError("An error occurred.");
var listener = new ConsoleTraceListener(); Trace.Listeners.Add(listener); Trace.TraceInformation("Informational message.");This code creates a new listener that outputs trace messages to the console and adds it to the Trace.Listeners collection. It then creates an informational message using the Trace class, which is sent to both the default listener and the new console listener. Package Library: System.Diagnostics.TraceSource.