The following example shows how to embed a trace switch and a trace listener inside the <system.diagnostics> element. The General trace switch is set to the TraceLevel.Error level. The trace listener myListener creates a file called MyListener.log and writes the output to the file.
<configuration>
<system.diagnostics>
<switches>
<add name="General" value="4" />
</switches>
<trace autoflush="true" indentsize="2">
<listeners>
<add name="myListener" type="System.Diagnostics.TextWriterTraceListener, System, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" initializeData="MyListener.log" traceOutputOptions="ProcessId, LogicalOperationStack, Timestamp, ThreadId, Callstack, DateTime" />
</listeners>
</trace>
</system.diagnostics>
</configuration>