How to log Trace messages with log4net?

前端 未结 4 431
北荒
北荒 2020-11-30 21:12

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

4条回答
  •  有刺的猬
    2020-11-30 21:42

    I don't know if log4net supports this, but you could implement your own trace listener that did this.

    The TraceListener doesn't have too many method that needs to be implemented and all you would do is to forward the values to log4net so this should be easy to do.

    To add a custom trace listener you would either modify your app.config/web.config or you would add it in code using Trace.Listeners.Add(new Log4NetTraceListener());

提交回复
热议问题