Good Habits for Structured Logging with Serilog

Below is a collection of good habits I’ve identified in my recent experiences with structured logging. The code examples are specific to Serilog, but the ideas can be applied to other structured logging tool sets (my stack of choice for .NET projects is Serilog, Elasticsearch and Kibana). Got your own structured logging practices to contribute? Share them on Twitter! Continue reading Good Habits for Structured Logging with Serilog

Structured Logging with Serilog and ELK

ThoughtWorks recently released their Technology Radar report for January 2015 and structured logging was among the techniques that they strongly suggested that the industry adopt. I’ve actually had some exposure to structured logging over the past year and have been very happy with the results. So, I thought I would share my experience. Continue reading Structured Logging with Serilog and ELK

Assertions in Moq Callbacks

I learned an important lesson today: do not assert inside of Moq callbacks. In the code below, even if the Assert.AreEqual fails, it will not cause the unit test to fail.

moqObj.Setup(m => m.Doit(It.IsAny<string>())).Callback<string>((s) => 
    Assert.AreEqual("foo", s);
// Insert test code that invokes `Doit`

You could use Verify instead, but it’s not always ideal, particularly when trying to step through the assertions while debugging tests. Instead, you can take this approach suggested by Thomas Ardal.

string actual = null;
moqObj.Setup(m => m.Doit(It.IsAny<string>())).Callback<string>((s) => 
    actual = s;
// Insert test code that invokes `Doit`
Assert.AreEqual("foo", actual);

A New Look for 2015

I have wanted to revamp my website for close to a year now. In that time I’ve looked into different blogging engines and tried creating new themes, but I didn’t settle on a path forward until a couple weeks ago.


At one point I considered moving to a statically generated site since they were all the rage. I tried out Jekyll and Middleman. I liked both and even wrote up a post on using Zurb’s Foundation with Middleman. However, I decided that by sticking with WordPress I could focus more on creating content.


Something that I really like about the static site generators is their first-class support for Markdown. I routinely write Markdown, so I felt that if I could generate my posts in Markdown, I would have one less hurdle for generating content. Before, I was using the WP-Markdown plugin, but I don’t like that it doesn’t retain the original Markdown content. Instead, it generates and saves the HTML when the post is saved, then converts it back to Markdown when editing the post. This probably works for most people, but I was having trouble with some of my code blocks getting messed up during the conversions. I decided to start using the Markdown feature in the Jetpack plugin. This plugin retains the original Markdown, and I’ve been very happy with it so far. This plugin also works well highlight.js, which I’m using for syntax highlight on the site.


The biggest problem I have had so far with maintaining my blog is generating posts. Over 3 years I have only published 31 posts, and only 2 in 2014. So, I decided to be more deliberate about pulling together post ideas and notes. I created a Trello board where I’m maintaining a list of post ideas and collecting notes for posts that I’m working on. I use other Trello boards for other purposes and have had a lot of success with them, so I’m hopeful that this will improve my content creation process.


I really liked the new Twenty Fifteen theme for WordPress, which is why I decided to base my new theme on it. I created the Block 15 child theme to add some customizations for my site. It has a lot of stuff hardcoded specifically for my website, but I decided to open source it on GitHub in case it could help anyone else interested in creating their own child theme.


I decided to drop my use of Disqus with the new theme. The Disqus thread always looked so ugly on the site and significantly increased the page load time. Instead, I added a Twitter link at the bottom of each post, encouraging readers to start a conversation about the post on Twitter. In addition to avoiding an ugly, long discussion thread on posts, this also increases my site’s overall visibility. Some users that have never been to my might observe a conversation on Twitter, and decide to check out my site as a result.

So, here’s to better year of blogging in 2015.