I saw a tweet today from the @ReactiveX account about a new release called Tx (LINQ to Logs and Traces). It appears to have a lot of plumbing to use the Reactive Extensions (Rx) to parse through Event Logs and Event Tracing files. One of the slides on the Tx Codeplex site also mentioned parsing IIS W3C Logs, which is something I spend a fair amount of time doing.
Even better Tx has a custom LINQPad Driver, which is one of my favorite tools for playing around with LINQ and Rx. I downloaded the sample traces and was able to view low level event tracing details from the HTTP.sys driver used by IIS, but I didn’t immediately see how to parse the IIS log files using Tx. After downloading the source I found a W3CTest.cs file that showed how to parse log files using the Tx.Windows.W3CEnumerable.FromFile or FromFiles methods.
To use this in LINQPad you do NOT need the Tx Driver, but instead you use F4 to add a reference to the Tx.Windows Nuget package:
Once the reference is added to your LINQPad query, you may also want to add the following additional namespace imports:
This gives you access to the common LINQ functions used in the Tx samples. Now I can write a query in LINQPad that uses the W3CEnumerable to parse the log files. You can write complex LINQ queries or use the toDataGrid parameter of the Dump method to display the data in a grid format:
After I had it working in LINQPad, I next thought: “Why can’t I use this in Powershell?”. The Tx library targets .NET 4.0 and 4.5, so as long as you have PS 3.0 or later you can add a reference to the Tx.Windows.dll and then use the W3CEnumerable class to work with Log files.
#Load Tx.Windows.dll from current user’s LINQPad nuget local cache
[Reflection.Assembly]::LoadFile("C:\Users\$($env:username)\AppData\Local\LINQPad\NuGet\Tx.Windows\Tx.Windows.1.0.31229\lib\Net40\Tx.Windows.dll")
#Load log file and sent output to screen
$log = [Tx.Windows.W3CEnumerable]::FromFile("C:\inetpub\logs\LogFiles\W3SVC1\u_ex131230.log")
$log | select -Last 10 | ft dateTime,cs_method,cs_uri_stem,cs_uri_query,cs_username,sc_status,time_taken
#Sent log to gridview
$log | out-gridview
The Gridview is very helpful since you can add filters to target specific entries similar to a LINQ query
All this in the first hour of playing with Tx! I am really excited to see if we can use Tx with IIS Failed Request Tracing or ASP.NET Tracing to track down issues in our .NET web apps.
2 comments:
Thanks for your post, this is great material. Tx is an open source project and therefore lives and breathes through contributions like this. Thank you.
We would love to see you contribute directly to the project, whether that be feature requests, bug reports, documentation or code. Don't hesitate to ask how to leverage Tx for your use case. See http://tx.codeplex.com/wikipage?title=Contributing
Khi có một loại thuốc mới ra đời thì những công dụng của nó chính là thứ chúng ta quan tâm đầu tiên chứ không phải là thành phần hay các thông tin nào khác. Kinh nghiệm dùng Fucoidan , đối với fucoidan cũng hoàn toàn tương tự như vậy, tác dụng của thuốc fucoidan chính là thông tin mà nhiều người trên khắp thế giới tìm hiểu. Liều dùng Fucoidan , công dụng chính được giới thiệu về sản phẩm này chính là việc nó kích thích các tế bào ung thư tiến hành quá trình tự diệt nhờ thế mà việc điều trị ung thư sẽ có chuyển biến tích cực hơn. Thuốc chữa ung thư Fucoidan ,một cách khác để nó hỗ trợ quá trình điều trị căn bệnh này đó là ngăn cản sự cung cấp dinh dưỡng cho các tế bào ác làm chúng bị tiêu diệt. Thực phẩm chức năng hỗ trợ điều trị ung thư Fucoidan. Không chỉ thế, người dùng còn được cho biết là khả năng tăng cường hoạt động của hệ tiêu hóa sau khi sử dụng sản phẩm này. Cách sử dụng Fucoidan, một công dụng khác mà chúng ta không sử dụng cũng có thể nhận biết được đó là việc đem đến làn da săn chắc, trắng mịn như những người dân hàn quốc nhật bản.
Post a Comment