简体   繁体   English

配置Postsharp日志工具包

[英]Configuring Postsharp logging toolkit

Using the free version of Postsharp, I added a logging aspect (using the toolkit, didn't code it myself). 使用Postsharp的免费版本,我添加了一个日志记录方面(使用工具包,我自己没有编写代码)。 Later I changed my mind and wanted to log only upon entering a function, and not on leaving. 后来我改变主意,只想在进入功能时登录,而不是在离开时。

Where can this be configured? 这可以在哪里配置? Couldn't find it anywhere. 无法在任何地方找到它。

Thanks! 谢谢!

Diagnostics configuration is stored in solution ( .pssln) or project level configuration file ( .psproj). 诊断配置存储在解决方案( .pssln)或项目级配置文件( .psproj)中。 These files may not contain required configuration tags or even they may be missing by default. 这些文件可能不包含必需的配置标记,或者默认情况下可能缺少这些标记。

You can open the configuration wizard from smart tag over any method without [Log] attribute. 您可以通过任何方法从智能标记打开配置向导,而无需[Log]属性。 The configuration you are interested in is on the first page (Logging Level). 您感兴趣的配置位于第一页(日志级别)。 Note that there is "New logging profile..." at the bottom of this page - you can have multiple configurations within one application. 请注意,本页底部有“新的日志记录配置文件...” - 您可以在一个应用程序中拥有多个配置。

If you change diagnostics configuration then pssln file is created after completing the wizard and it should contain something like this: 如果更改诊断配置,则在完成向导后创建pssln文件,它应包含以下内容:

<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.postsharp.org/1.0/configuration" xmlns:d="clr-namespace:PostSharp.Patterns.Diagnostics;assembly:PostSharp.Patterns.Diagnostics" xmlns:p="http://schemas.postsharp.org/1.0/configuration" xmlns:p1="http://schemas.postsharp.org/1.0/configuration">
  <Property Name="LoggingEnabled" Value="{has-plugin('PostSharp.Patterns.Diagnostics')}" Deferred="true" />
  <d:LoggingProfiles p:Condition="{$LoggingEnabled}">
    <d:LoggingProfile Name="Default" OnExceptionLevel="None" OnSuccessLevel="None" />
  </d:LoggingProfiles>
</Project>

The interesting tag is d:LoggingProfile with it's attributes OnExceptionLevel and OnSuccessLevel. 有趣的标签是d:LoggingProfile,它的属性是OnExceptionLevel和OnSuccessLevel。 You can add this configuration file manually as well. 您也可以手动添加此配置文件。

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

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