Implementé un detector de seguimiento personalizado (derivado de TextWriteTraceListener
) y ahora me gustaría configurar mi aplicación para usarla en lugar del estándar TextWriteTraceListener
.Cómo definir TraceListener personalizado en app.config
Primero he agregado el valor predeterminado TextWriteTraceListener
para asegurarme de que funciona bien y lo hace. Aquí está mi app.config:
<configuration>
<system.diagnostics>
<trace autoflush="true" indentsize="4">
<listeners>
<add name="TextListener" type="System.Diagnostics.TextWriterTraceListener" initializeData="trace.log" />
<remove name="Default" />
</listeners>
</trace>
</system.diagnostics>
</configuration>
Ahora mi rastro de detector se define en MyApp.Utils
espacio de nombre y se llama FormattedTextWriterTraceListener
. Así que cambió el tipo en la configuración anterior para MyApp.Utils.FormattedTextWriterTraceListener
y en la actualidad se ve así:
<configuration>
<system.diagnostics>
<trace autoflush="true" indentsize="4">
<listeners>
<add name="MyTextListener" type="MyApp.Utils.FormattedTextWriterTraceListener" initializeData="trace.log" />
<remove name="Default" />
</listeners>
</trace>
</system.diagnostics>
</configuration>
Sin embargo, ahora cuando trato de entrar algo de lo que estoy poniendo un ConfigurationErrorsException
con el mensaje:
Couldn't find type for class MyApp.Utils.FormattedTextWriterTraceListener.
¿Alguien sabe cómo puedo configurar este oyente personalizado en config y si es posible?
nombre de Asamblea es 'MyApp' y añadió que al argumento de tipo – RaYell
edité puesto, intenta especificar el estilo –
Esto está dando un mensaje diferente (igual tipo de excepción) 'No se pudo crear MyApp.Utils.FormattedTextWriterTraceListener, MyApp. – RaYell