简体   繁体   English

锐化后将日志记录到C#中的文本文件

[英]Postsharp logging to a text file in C#

I am fairly new to using PostSharp. 我对使用PostSharp很陌生。 I have been able to get it to output trace messages to a the System.Console backend, but can anyone give me a basic sample as to how output the trace messages to a simple text file please? 我已经能够将跟踪消息输出到System.Console后端,但是任何人都可以给我一个有关如何将跟踪消息输出到简单文本文件的基本示例吗?

What you could do is, 你能做的是

  • implement some kind of logging service (or just use an existing library, for example log4net) 实现某种日志记录服务(或仅使用现有的库,例如log4net)
  • create an aspect which will then use that log service to write your stuff to the log file 创建一个方面,然后将使用该日志服务将您的内容写入日志文件

Update : 更新

There is an extension for PostSharp using Log4Net, see 使用Log4Net的PostSharp有一个扩展,请参阅

http://www.postsharp.net/blog/post/postsharp-toolkits-update-support-for-log4net-and-system-diagnostics-trace http://www.postsharp.net/blog/post/postsharp-toolkits-update-support-for-log4net-and-system-diagnostics-trace

Just google for log4net and PostSharp, it will point you in the right direction. 只需在谷歌搜索log4net和PostSharp,它将为您指明正确的方向。

http://www.lobsterfs.co.uk/blog/postsharp-and-log4net/ http://www.lobsterfs.co.uk/blog/postsharp-and-log4net/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM