I\'m using log4net to log write log message to a rolling log file.
Now I would also redirect all trace messages from System.Diagnostics.Trace to that l
As per the answers above, there's an implementation here (this link is flaky, but I did find the source code):
https://code.google.com/archive/p/cavity/
To crudely deal with the issue (described in the comments to a previous answer) of internal log4net trace issuing from the LogLog class, I checked for this class being the source of the trace by inspecting the stack frame (which this implementation did already) and ignoring those trace messages:
public override void WriteLine(object o, string category)
{
// hack to prevent log4nets own diagnostic trace getting fed back
var method = GetTracingStackFrame(new StackTrace()).GetMethod();
var declaringType = method.DeclaringType;
if (declaringType == typeof(LogLog))
{
return;
}
/* rest of method writes to log4net */
}
Using a TraceAppender will still create the problems described in the comments above.