【问题标题】:Can I replace SLAB one-method-per-event with types?我可以用类型替换 SLAB 一个方法一个事件吗?
【发布时间】:2016-07-11 14:11:09
【问题描述】:

Examples for SLAB 看起来像这样:

MyCompanyEventSource.Log.ScalingRequestSubmitted(
    request.RoleName, 
    request.InstanceCount,
    context.RuleName,
    context.CurrentInstanceCount);

我不喜欢每次添加新事件类型时都必须编辑MyCompanyEventSource。我也不喜欢记录器只能静态使用。我宁愿有这样的东西:

_logger.Log(new ScalingRequestSubmittedEvent(request, context));

我知道我可以自己进行日志记录,但在我完全解雇 SLAB 之前,我想知道我是否不公平。

【问题讨论】:

    标签: c# logging slab


    【解决方案1】:

    没有办法做这样的事情

    _logger.Log(new ScalingRequestSubmittedEvent(request, context));
    

    而且您必须随时更改您的记录器以添加新类型的事件、更改信息级别或关键字。

    为 EventSource 编写自己的包装器是实现所需功能的唯一方法。

    【讨论】:

      猜你喜欢
      • 2016-01-04
      • 1970-01-01
      • 1970-01-01
      • 2010-10-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多