Sep 15

NLog Quick Hit – Using netcat as a remote log viewer

I was looking for an easy way to get access to NLog output remotely. Specifically, I wanted to view the logs coming from a virtual machine running on Parallels (with our app running on it) on my Macbook Pro. Our new app has great log coverage and often checking the log output is quicker than firing up the debugger to diagnose development issues. I was pretty unhappy with all the options I found for remotely viewing the log output. Then I remembered Netcat.

Netcat is an old unix program that, amongst other things, can open a raw TCP connection on a port and dump the contents to the screen. Turns out that you can use netcat (nc on OSX) to make an ad-hoc remote log viewer.

First set up NLog with a Network target:

  <target xsi:type="Network"
      layout="${uppercase:${level}} ${callsite} ${message} ${exception:innerFormat=Message,Type,Method:maxInnerExceptionLevel=5:innerExceptionSeparator=->:separator=|:format=Message,Type,Method}"
      address="tcp://" />
  <logger name="*" minlevel="Trace" writeTo="osxnc" />

Then, on the computer you want to use to view the log output, start netcat (l means listen and k keeps the connection open even after a client disconnects):

nc -lk 12121

And your logs dump to the screen in real time!

DEBUG Zeroarc.Candid.Service.WorkflowService`1+<ChangeScheduleDate>d__30.MoveNext ChangeScheduleDate succeeded: result=1, objectId=53, userId=2, stateId=19, date=10/20/2015 12:00:00 AM
DEBUG Zeroarc.Candid.Service.WorkflowService`1+<ChangeScheduleDate>d__30.MoveNext ChangeScheduleDate succeeded: result=1, objectId=53, userId=2, stateId=19, date=11/20/2015 12:00:00 AM
DEBUG Zeroarc.Candid.Service.WorkflowService`1+<ChangeScheduleDate>d__30.MoveNext ChangeScheduleDate succeeded: result=1, objectId=53, userId=2, stateId=19, date=11/17/2015 12:00:00 AM

Netcat has a ton of other helpful uses as well, especially when debugging opaque and poorly logged software.

Aug 14

AWS quick hit – configure Elastic Beanstalk with cross zone load load balancing and connection draining

I spent a long time trying to find the exact syntax for this yesterday. Hope it helps save someone else some time.

If you are using Amazon’s Elastic Beanstalk and want to get your Elastic Load Balancers using cross zone load balancing and/or connection draining, you will need to create an .ebextensions folder with a file with a .config extension that has the following content:


    Type: AWS::ElasticLoadBalancing::LoadBalancer
      CrossZone: True
      ConnectionDrainingPolicy: {"Enabled" : True, "Timeout" : 300 }

In other news, I intend to start posting here regularly again. Most of my recent posts have been on my team’s blog: Soccer & Code, but I’ll start giving fzysqr some more love, promise!

Aug 13

Technical Overview of Golazo

Yesterday, I released a post on the MLS Dev Blog detailing our newest product, Golazo:

The idea was basically this: ingest stats, news, social content, chat, photos, videos, and live streams and create a single place for our fans to park their computers or tablets or phones during a match that they were already watching on television or MLS Live. The goal was to create the best second screen experience in sports.

Check it out! and let me know what you think. @jdslatts

Jul 13

Introducing stacklog for Node.js

Hey! I just released a cool little Node.js utility called stacklog. It makes it easier to add helpful logging prefixes through your debug statements in your apps.

Your truly, writing for MLS Dev Blog:

I am currently laid up from a recent hand injury, involving a bottle of wine and and a bad idea. Ironically, despite only having 1.2 hands to use for typing (pinky on right hand), being stuck at home has actually made it easier to get through some of my hacking todo list. The first item on that list is to release a little utility I have been using lately: stacklog.

Read the whole article at the MLS Dev blog or go straight to the good stuff on npm or github. As always, let me know what you think! @jdslatts on twitter or using the comments link below.

May 13

Taking SaltStack to The Next Level With Pillars and Python States

This is a cross post from a post I wrote for the MLS Digital Dev Blog. -Justin


For those of us who come from traditional sysops backgrounds, learning Salt means un-learning many of our shell scripting habits. Continue reading →

Jan 13

Be The Master Of Your Minions (An Introduction To Salt)

Happy new year fzysqr readers! What better way could we possibly celebrate the new year than by trying a new infrastructure automation system? Late last year, I began rolling out Salt a.k.a. SaltStack (for SEO help I’m told).

Continue reading →

Aug 12

Quick Tip – Wrong SSH Key Cached With Github After Changing Users and Keys

If you find that you are unable to access Github after switching out your private keys, you may have a key cached with ssh agent. To diagnose:

ssh git@github.com -v

Look for something along the lines of “debug1: Remote: Forced command: gerve someuser”. If you see this, you have a cached key. To fix:

killall ssh-agent
exec ssh-agent bash
ssh-key -D

You should see “All identifies removed” followed by “Identity added: //.ssh/id_rsa”. Now you should be able to successfully do:

ssh git@github.com
Apr 12

A Smarter FileBasedCache for Django

A quick follow up on my previous post about a few minor issues we recently experienced with the Django FileBasedCache. I mentioned that we commented out a line of code in the framework in order to get the application running correctly in production. Of course that wasn’t going to be the permanent fix.

Continue reading →

Apr 12

Update to VimRepressed

So apparently OSX Lion and Vim plugins implemented in python are not playing well together.

Calls to sys.stdout.write() and sys.stderr.write() appear to be crashing vim core. I say appear becauses it nearly impossible to debug. Rather than bang my head against the wall all night or do some brew compiling gymnastics, I just switched the stdout/stderr calls to use an even more pythonic style:

print >> sys.stderr, 'Blah'

Works great. Get your fresh code fixes here.

Mar 12

Django Cache and Burn

As part of our Amazon EC2 design, we decided to use S3 as our persistence layer; durability and easy storage growth for our data is very important to us. We knew that S3 would be to slow on its own for real time access. Luckily for us, the use profile of our application fits perfectly with a write-through cache strategy. Our users generally need a single dataset accessible for a week or two before they finish their analysis and move on, most likely never to access it again. Django’s file based cache seemed ideal. We could point it at the generous (and otherwise unused) instance storage on our EBS backed AMIs and cache several hundred gigabytes of data. If we lose a sever there would be performance penalty as the working dataset was built back up through a read-through strategy, but nothing unacceptable for a short period of time.

Continue reading →