任何有 Postsharp 生产经验的人? [英] Anyone with Postsharp experience in production?

查看:23
本文介绍了任何有 Postsharp 生产经验的人?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有人在生产环境中使用过 Postsharp AOP 框架?有什么陷阱吗?为了做一些日志等,Postsharp 可以和 Log4Net 一起使用吗?

Has anyone out there used Postsharp AOP framework in a production environment? Are there any pitfalls? In order to do some logging etc, can Postsharp be used in conjunction with Log4Net?

任何有关将 Postsharp 与 Web Apps 和/或 Log4Net 结合使用的教程将不胜感激.

Any tutorials on using Postsharp with Web Apps and/or Log4Net will be highly appreciated.

推荐答案

我和另一位团队成员以不同的方式使用 PostSharp,这些项目已投入生产并已持续数月.例如,在一种情况下,我使用它来记录异常情况下的方法参数值.PostSharp 老挝(包含在 PostSharp 中)是一种易于使用的方法调用注入方式(例如,在方法进入、退出和异常时),您可以轻松地向 log4net 注册记录器添加日志调用.

I and one other teammate use PostSharp in different ways on several projects that are in production and have been for months. For example, in one case, I use it to log method parameter values in case of an Exception. PostSharp Laos (included in PostSharp) is an easy to use way of injecting method calls (on method entry, exit and on exceptions, for example) and you could easily add log calls to log4net registered loggers.

它增加了构建时间,足以稍微改变我的构建习惯,但对于它提供的好处来说肯定不会太多,IMO.在编写代码时,您可能希望将其从本地构建中排除,这很容易做到,因此您可以继续频繁快速地构建,然后将其包含在您的构建服务器等中.

It has increased build times, enough to slightly change my build habits, but certainly not too much for the benefits it provides, IMO. While writing code, you may wish to exclude it from your local build, which is easy enough to do, so you can continue to build frequently and quickly, then include it on your build server etc.

这是来自 Gael(PostSharp 创建者)的 好的 PostSharp 教程...虽然它很旧,但很高兴看到它的运行.到目前为止,在我遇到的控制台、winforms、WPF 或 WebApp 中使用它确实没有区别.

Here's a good PostSharp tutorial from Gael (the PostSharp creator)... though it is old, it's nice to see it a run-through. There is really no difference in using it in a console, winforms, WPF or WebApp that I've encountered so far.

我还想说,一旦您弄清楚如何将老挝方面添加到项目中,重复这个练习就很容易了.您应用方面的程序集/类的数量与 PostSharp 为您的构建增加的时间之间存在关系.因此,您甚至可以稍微控制构建时间问题.

I would also say that once you've figured out how to add Laos aspects to a project, repeating the exercise is very easy. And there is a relationship between how many assemblies/classes you apply the aspects to and how much time PostSharp adds to your build. So you can even control the build time issues a bit.

至于代码,PostSharp 的工作方式给我留下了非常深刻的印象……它从来没有搞砸过构建、使程序集无效或以其他方式搞砸了代码.我什至在 ASP.NET 应用程序中使用了它,具有代码覆盖率和性能检测(因此它可以很好地与 MS 的汇编检测工具配合使用).

As for the code, I am very very impressed with how well PostSharp works... it has never screwed up a build, made an assembly invalid or otherwise messed up code. And I have even used it in ASP.NET apps, with code coverage and performance instrumentation (so it's played nicely with MS' Assembly instrumentation tools).

总而言之,我愿意.建议您根据自己的 log4net 要求尝试一下.

All in all, I would def. recommend you try it out for your log4net requirements.

这篇关于任何有 Postsharp 生产经验的人?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆