I have an asp.net app hosted in iis. it works as web api rest service. I write a log which is configured as:
<source ...>
<listeners>
<add ... />
</listeners>
</source>
I added nuget for web api tracing and it prints ok in my visual studio. the tracing configured in webapiconfig.cs as:
config.EnableSystemDiagnosticsTracing();
I would like to redirect the output into the existing log..
any ideas?
public class WebApiTracer : ITraceWriter
{
public void Trace(HttpRequestMessage request, string category, System.Web.Http.Tracing.TraceLevel level, Action<TraceRecord> traceAction)
{
TraceRecord rec = new TraceRecord(request, category, level);
traceAction(rec);
WriteTrace(rec);
}
protected void WriteTrace(TraceRecord rec)
{
var message = string.Format("WebApi. {0};{1};{2};{3};{4}",
rec.Category, rec.Operator, rec.Operation, rec.Message, rec.Exception);
myLog.Write(message);
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.