惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

GbyAI
GbyAI
博客园_首页
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
阮一峰的网络日志
阮一峰的网络日志
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园 - 司徒正美
V
V2EX
Cloudbric
Cloudbric
Hugging Face - Blog
Hugging Face - Blog
腾讯CDC
量子位
博客园 - 三生石上(FineUI控件)
博客园 - 叶小钗
K
Kaspersky official blog
博客园 - 【当耐特】
T
Tenable Blog
L
Lohrmann on Cybersecurity
The Cloudflare Blog
S
Schneier on Security
A
Arctic Wolf
Latest news
Latest news
C
Cyber Attacks, Cyber Crime and Cyber Security
罗磊的独立博客
T
The Exploit Database - CXSecurity.com
Cisco Talos Blog
Cisco Talos Blog
小众软件
小众软件
P
Privacy & Cybersecurity Law Blog
WordPress大学
WordPress大学
Simon Willison's Weblog
Simon Willison's Weblog
雷峰网
雷峰网
NISL@THU
NISL@THU
人人都是产品经理
人人都是产品经理
月光博客
月光博客
J
Java Code Geeks
V
Visual Studio Blog
S
Security Affairs
博客园 - Franky
T
Tailwind CSS Blog
Apple Machine Learning Research
Apple Machine Learning Research
H
Heimdal Security Blog
有赞技术团队
有赞技术团队
V2EX - 技术
V2EX - 技术
AWS News Blog
AWS News Blog
G
GRAHAM CLULEY
T
Troy Hunt's Blog
SecWiki News
SecWiki News
Spread Privacy
Spread Privacy
宝玉的分享
宝玉的分享
www.infosecurity-magazine.com
www.infosecurity-magazine.com
博客园 - 聂微东

博客园 - 生鱼片

Gitlab安装过程 SharePoint 2013即SharePoint 15的一些新特性 关于虚机克隆模板导致无法添加域用户的问题 http header Content-type SharePoint 2010 文档库中直接打开文档 使用SymbolResolver在Activity内访问宿主环境信息 增加一个Export to Spreadsheet的链接 WF4:自定义跟踪参考者 WF4集合Collection相关活动用法 SharePoint 2010 BI(2):使用Visio Service SharePoint 2010 BI (1):Chart WebPart 微软WebMatrix介绍 使用Sharepoint 2007中的webservice操作列表 - 生鱼片 - 博客园 SharePoint中CAML使用的一些总结 使用SharePoint Designer 2010 创建 外部内容类型 WF4:同步执行工作流 - 生鱼片 - 博客园 SharePoint 2010中托管元数据 SharePoint 2010中的客户端模型 SharePoint 2010中的Content Query WebPart
WF4:ETW跟踪参与者
生鱼片 · 2011-01-23 · via 博客园 - 生鱼片

WF4中的跟踪服务是通过跟踪参与者直接监听运行时放出的跟踪记录,并以根据选择的方式来处理它们。我们可以将日志记录到不同的媒介中,本文我们看看WF4中支持的ETW跟踪参与者。

Windows® 事件跟踪 (ETW) 是操作系统提供的一个高速通用的跟踪工具。ETW 使用内核中实现的缓冲和日志记录机制,提供对用户模式应用程序和内核模式设备驱动程序引发的事件的跟踪机制。此外,ETW 使您能够动态地启用和禁用日志记录,轻松地在实际生产环境下进行详细跟踪,而无需重新启动系统或重新启动应用程序。日志记录机制使用每处理器的缓冲区,由异步写线程将这些缓冲区写入磁盘。这样,大型服务器应用程序在写入事件时所受的干扰能够降至最小。

我们新建一个工作流项目,工作流的设计中我们随便加上几个Activity即可,如下:

clip_image002

下面我们来看看如何配置ETW跟踪,代码如下:

//ETW tracking setup

TrackingProfile trackingProfile = new TrackingProfile();

trackingProfile.Queries.Add(new WorkflowInstanceQuery

{

States = { "*"}

});

trackingProfile.Queries.Add(new ActivityStateQuery

{

States = { "*" }

});

trackingProfile.Queries.Add(new CustomTrackingQuery

{

ActivityName="*",

Name="*"

});

EtwTrackingParticipant etwTrackingParticipant = new EtwTrackingParticipant();

etwTrackingParticipant.TrackingProfile = trackingProfile;

在上面代码中我们可以选择记录那些跟踪信息,这个信息是通过跟踪配置文件来完成的,可以根据你的需求来定制,完成之后我们需要将etwTrackingParticipant以扩展点的方式添加到工作流中,代码如下:

AutoResetEvent autoResetEvent=new AutoResetEvent(false);

WorkflowApplication workflowApplication = new WorkflowApplication(new Workflow1());

workflowApplication.Completed = (arg) => { autoResetEvent.Set(); };

workflowApplication.Extensions.Add(etwTrackingParticipant);

workflowApplication.Run();

autoResetEvent.WaitOne();

之后我们运行工作流,结果很简单:

clip_image004

我们打开windows的事件查看器,切换到下图位置可以到有相关的信息记录在上面,这就是工作流运行后的信息:

clip_image006

我们可以看到工作流运行的详细信息如下:

clip_image008