The task is not to gather Performance counters data in my .NET app, but open already prepared binary log files (*.blg)?
I know that MS SQL Profiler (.NET app) can parse binary logs.
C is a general-purpose programming language created by Dennis Ritchie at the Bell Laboratories in 1972. It is a very popular language, despite being old. C is strongly associated with UNIX, as it was developed to write the UNIX operating system.
C is one of the earliest and most widely used programming languages. C is the fourth most popular programming language in the world as of January 2022. Modern languages such as Go, Swift, Scala, and Python are not as popular as C. Where is C used today?
C is an imperative procedural language supporting structured programming, lexical variable scope, and recursion, with a static type system. It was designed to be compiled to provide low-level access to memory and language constructs that map efficiently to machine instructions, all with minimal runtime support.
The C programming language will turn fifty years old in 2022. Yet despite its long history, C remains one of the top "most-used" programming languages in many "popular programming languages" surveys. For example, check out the TIOBE Index, which tracks the popularity of different programming languages.
From what I can find it seems that the .blg file format is proprietary and the spec is not openly published. That said I don't think you will be able to find a framework or library that does raw parsing of this format. Writing a library to parse this format without the spec is not without risk since assumptions will likely have to be made... even if you were to reverse engineer the binary format there is always the chance that you miss certain rules in your parser implementation causing potential problems down the road.
That said, I can think of 2 other options for parsing binary log files for use within a .NET application.
PowerShell's Import-Counter cmdlet could be used to import counter data from a blg file resulting in objects for each counter sample in the source. The resulting output can be used in a number of ways. The simplest example I can think of would be to convert your source to CSV format for further processing:
C:\PS> $data = import-counter .\exampledata.blg
C:\PS> $data | export-counter -path .\output.csv -FileFormat csv
relog is another option. This is a command line utility that ships with most major versions of the Windows OS. Again, the approach here would be to convert the blg file into CSV format for easy parsing. Example:
relog -f csv inputfile.blg -o outputFile.csv
Given the options above you should be able to go from there. It would be quite easy run powershell or relog from a C# program using Process.Start()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With