开发者

Can I write my owm template in TextFormatter used in Logging Application Block in C#?

Can I write my owm template in TextFormatter used in Logging Application Block in C#?

Basically I want开发者_高级运维 to write my exception log in atext file and in specific format where I want to include database information and software version.


Here you can find more information about extending the Logging Application Block.


You can make different listeners for text writing and database writing. You can then point the listeners to different text formatters you can change format of the data. However you have to organise the message you pass to it first. The default text formatter has allot of extra information you may or may not want.

Here is a example of a changed text formatter you can have as many listeners and formatters as required. This will change your text file without having to change the code.

Thanks Alex

  <add type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
    template="{message}{newline}"
    name="TextAuditFormater" />
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜