Scott Hanselman

NuGet Package of the Week: MarkdownLog makes log files much prettier

July 30, '14 Comments [9] Posted in NuGet | NuGetPOW
Sponsored By

While I'm not 100% gaga over Markdown as I know many of you are, I definitely appreciate it's usefulness and it's clarity. Some folks would say I shouldn't rest until every binary document on my hard drive has been converted to Markdown. I say, nay nay. That said, I totally dig MarkdownPad and you should use it every day. It's lovely.

If you don't want to install anything, check out and quickly edit some Markdown in the browser.


But, I digress.

Note: Be sure to check out all the NuGet packages of the week! There's more!

The general idea behind Markdown is that HTML is way too complex for 90% of what you need, so rather than <ul> and <li> and all that, why not just express bullets with asterisks? We can all get behind that. There are many other simple Markdown syntaxes that you can learn in a few minutes. Once you've created some Markdown, you can easily generate PDFs, HTML, Word Documents, whatever you like.

Recently I stumbled upon Stuart Wheelwright's article on Using Markdown for Effective Logging over at CodeProject. Here's the first image borrowed from his excellent article where he clearly shows why Markdown is simpler than HTML:


Stuart has taken Markdown and created a wonderful little library called MarkdownLog. It's a brilliant little idea that one of us should have come up with first! Kudos to Stuart. ;)

[MarkdownLog] is designed to make it trivial to produce Markdown formatted text from an application's data structures. Using just one line of code, a collection of .NET objects can be output as a table or list. And, because the output is Markdown, it can later be converted to HTML for publishing, if needed.

Even better, MarkdownLog is a Portable Class Library (PCL) and can be used with any .NET platform, including iOS with Xamarin. In fact, it's an iPhone app written with Xamarin that compelled Stuart to write MarkdownLog.

Here's one of his first examples. This C# code:

var myStrings = new[] { "John", "Paul", "Ringo", "George" };

Gives you this simple Markdown.

   * John
* Paul
* Ringo
* George

At this point, you are likely unimpressed. But wait! There's more! There's a whole series of nice extension methods that make it easy to create templates from objects of any shape. Here's another example of his:

var data = new[]
new{Name = "Meryl Streep", Nominations = 18, Awards=3},
new{Name = "Katharine Hepburn", Nominations = 12, Awards=4},
new{Name = "Jack Nicholson", Nominations = 12, Awards=3}


This gives you a Markdown table, of course. This looks nothing like an HTML table, but remember, Markdown is source code that can be translated into other formats like HTML and PDF.

 Name              | Nominations | Awards
----------------- | -----------:| ------:
Meryl Streep | 18 | 3
Katharine Hepburn | 12 | 4
Jack Nicholson | 12 | 3

Be sure to explore the full CodeProject article and the home page for MarkdownLog. Think about how you could add this to your existing logging framework and create better logs for tests, builds, anything. Take a look at the HTML render of one of Stuarts's Test Suite Runs and tell me that you want immediately want to get to work updating your old .LOG files.

Related Links

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by ORCS Web
Wednesday, July 30, 2014 4:57:58 PM UTC
WebEssentials has some nice Markdown features too.
Andrew Coats
Wednesday, July 30, 2014 6:10:47 PM UTC
While I see the use of Markdown for things like code blocks with syntax highlighting, I don't see the benefit for simple cases like lists and tables. In fact, authoring a table in Markdown syntax seems way more annoying than writing the equivalent HTML.
Sunday, August 17, 2014 5:08:59 PM UTC
You can consume the polk salad leaves that way, or drain and toss
in a skillet using a couple of teaspoons of bacon drippings and stir fry them for about one minute.
For mild to moderate psoriasis, topical creams will be the treatments of choice.

Acai berry contains important antioxidants called Anthocyanins which eradicate toxins within us to keep the body
functioning. The five leaves on each stem should really symbolize the elements in perfect harmony.

Last week I met among my friend, He is also a fantastic article writer and write articles
for a number of web development companies.
Make each paragraph intriquing, notable and appealing with a fresh supportive idea
which could possibly be a connecting link to the idea in the previous paragraph.
Phytolacca decandra whether ([]( "")) You don't need to be an highest rated writer to write down effectively to the
extent of having your individual original articles published on article directories for the internet.
You can, as an example, choose to create about your role model and just how he
or she has helped you deal together with your disability.
Friday, September 19, 2014 7:10:35 PM UTC
I feel this is among the so much vital information for me. And i am satisfied
reading your article. But wanna remark on some common things, The website taste is wonderful, the articles is actually great
: D. Just right process, cheers
Saturday, September 20, 2014 4:26:00 PM UTC
Companies like Monsanto are unlikely in the GM business
for purely noble reasons. Indian shoppers are getting smart by the
day, and they want to enjoy everything like their western counterparts.
There are cures readily obtainable in the
marketplace these days, but with the hazards of the side consequences that you may
possibly get from these business cures, it would be a sensible plan to think about
some organic cures that are also established helpful just like their commercial counterparts.
Sunday, September 21, 2014 4:51:18 AM UTC
I'm really enjoying the design and layout of your site.
It's a very easy on the eyes which makes it much
more pleasant for me to come here and visit more often. Did you hire out a developer to create your theme?
Exceptional work!

My web-site ... best Upright exercise bike ([]( ""))
Tuesday, September 23, 2014 5:49:14 PM UTC
Write more, thats all I have to say. Literally, it seems as though yoou relied on the video to make your point.
You clearly know what youre talking about, why thrdow away your
intelligence on just posting videos to your weblog when you
could be giving us soomething eenlightening tto read?

Look into my website; [top porn sites]( "top porn sites")
Tuesday, September 23, 2014 8:17:54 PM UTC
I'm gone to say to my little brother, that he should
also pay a quick visit this blog onn regular basios to get updated from
ost up-to-date information.

Feel free to surf to my website :: [porn suggestions]( "porn suggestions")
Saturday, September 27, 2014 9:16:56 AM UTC
Have you ever considered about including a little bit more than just your articles?
I mean, what you say is fundamental and everything. However think of if you added some great images or
videos to give your posts more, "pop"! Your content
is excellent but with images and clips, this site could certainly be
one of the very best in its niche. Fantastic blog!

my weblog - [can ho tan phuoc quan 11]( "can ho tan phuoc quan 11")
E-mail (will show your gravatar icon)
Home page
Comment (Some html is allowed: a@href@title, b, blockquote@cite, em, i, li, ol, pre, strike, strong, sub, super, u, ul) where the @ means "attribute." For example, you can use <a href="" title=""> or <blockquote cite="Scott">.
Live Comment Preview

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.