DaedTech

Stories about Software

By

Logging for Fun: Things You’d Never Thought to Log

Editorial Note: I originally wrote this post for the LogEntries blog.

I work as a consultant in the software industry.  This work affords me the opportunity to see and interact with many different teams and thus to observe prevailing trends.  Among these teams, the attitude toward logging tends to be one of resigned diligence.

That is, many developers view application logging the way they view flossing their teeth: a necessary, dull maintenance activity that will pay dividends later.  Today, however, I’d like to encourage readers to consider a different side of logging.  In the right context and with the right intent, the activity can do so much more than simply insulate against audits and facilitate troubleshooting.  Logging can, in a sense, offer similar appeal to journaling or generally recording information for posterity.

Logging loosely consists of two components: recording and storing information.  As application developers, we find our thoughts occupied by the recording and how that affects our code.  We consider the storage and retrieval only inasmuch as it later aids our debugging efforts.  But we can expand the storage to include sophisticated aggregation, filtering, and querying techniques.  And in these techniques, we can find new ways to understand subjects that interest us.

To be a bit more concrete, I’m going to offer some examples in this post of worlds that you can open through logging.  But the examples will require you to view logging not as dumping data to some file, but as recording information in a way that you can mine it for meaning.  Obviously not all of us share the same interests.  But these examples may give you ideas for your own interests, even if they do not all appeal to you directly.

Read More

By

Logging the Lights in Your Home

Editorial Note: I originally wrote this post for the LogEntries blog.  You can find the original here, at their site.  While you’re there, check out the log aggregation service they offer and see if you could use some help storing and querying your log files.

It’s all the rage these days under the general heading of “Internet of Things” (IoT), but I have been a home automation enthusiast for more than 10 years now.  In the interceding time, I’ve done experiments and written about the subject.  I even published a Pluralsight course, in which I turned a Raspberry Pi into a RESTful server that lets you turn lights in your house on and off using basic X10 technology.  You can certainly say I have a lot of experience, both with newer techs and comparably archaic ones.

Because I’ve been in the game so long, you might think that I’m a strict constructionist, if you will, wanting to build everything myself from raw parts.  But I’m not.  Even though I enjoy assembling these systems from their components, I am a fan of the strides made by various vendors over the years, and I’m thrilled to see different players enter the space and expand home automation mind share in the general public.  In fact, I’m excited as a technologist that I can leverage already-assembled techs and services to achieve my home automation goals.

Introducing Wink

Against this backdrop, my mom recently gave me a Wink hub and companion lights for my birthday.  Wink is a service that does what I once quixotically sought to do in my spare time on weekends: it unifies disparate smart devices to allow centralized control over them.  The hub is synced with the Wink service in general, allowing control from anywhere, and the hub communicates over house Wifi with the satellite devices.  I can now turn on a couple of lights from anywhere in the world, with the workflow occurring as follows.

  1. I pop out my phone while vacationing somewhere sunny, open the Wink app, and tell it to turn on my master bedroom light.
  2. The Wink app phones home to the wink servers, communicating this request.
  3. The Wink servers pass the message on to my connected Wink hub at home.
  4. The Wink hub relays the message over Wifi to the light, which turns on.

It’s really pretty slick.  It also causes me a wry smile of amusement, since I just got a birthday gift that does out of the box something I worked for months to make happen.  But then I trade that smile for a genuine one when I think about how much more I can do in this landscape.

Read More

By

Avoid these Things When Logging from Your Application

Editorial note: I originally wrote this post for the LogEntries blog.  You can check out the original here, at their site.  While you’re there, sign up for the service and check it out.

It seems almost strange to talk about avoiding things while logging.  After all, logging is your last line of defense or your salvation in many cases.  Some crazy bug in the field that shows up every third full moon?  An external auditor looking at your app’s runtime behavior?  Logging to the rescue.

So naturally, is stands to reason that you would want to log just about everything your application.  Whenever there’s any doubt, slam a logger call in there and let log level sort out the details.  You can always filter logs, but you can’t magic stuff into them after the fact.  So why, then, talk of avoidance?

wizard

Well, it turns out that, while logging may be a highly inclusive activity in terms of what should be included, there are ways to create problems.  You want to be liberal in terms of what you log, but judicious and wise in terms of how you log it.  You don’t want to indulge in a feckless free-for-all when it comes to the calls you make to your application’s logger.

So what are these problems, and how to avoid them?  Let’s take a look at some things that can come back to bite you.

Read More

By

Keeping Your Code Clean while Logging

Editorial Note: I originally wrote this post for the LogEntries blog.  You can check out the original here, at their site.  While you’re there, take a look at their product offering that handles your log aggregation, search, and alerting needs.

In my consultancy practice, one of the things that I do most frequently is help teams write so-called “clean code.”  Usually, this orients around test-driven development (TDD) and writing code that is easily maintained via regression tests and risk-free refactoring.  Teams want to understand how to do this, and how to do it in their production code (as opposed to in some kind of toy “let’s build a calculator” exercise).

BrandNewSetup

One of the most prominent, early sticking points that rears its head tends to be application logging.  Why?  Unit testing is all about isolating objects, instantiating them, and rapidly verifying their behavior in memory.  Logging is all about dumping as much information as possible to a file (or database, service, etc with appenders) from as many places as possible.  Unstoppable force, meet immovable object.

For instance, consider the following C# code from a “let’s build a calculator” exercise.

Life here is good.  The calculator’s add method returns the sum of the integers, and we have a test method that supplies 2 and 2, and confirms a result of 4.  That’s a screaming fast, very clear test.  But, consider what happens if we amend our calculator to take advantage of logging.

Now, with that same test, everything goes wrong.  Instead of passing, it throws an exception about not having write access to some weird directory on your machine that you’ve never even heard of.  After digging a bit, you see that it’s the directory in which the test runner executes when running your solution’s tests.  Hmmm.

Read More

By

Logs for SEO

Editorial Note: I originally wrote this post for the LogEntries blog.  You can check out the original here, at their site.  While you’re there, check out the features of their offering.

I write blog posts on a number of different sites that are not my own, and that is an exercise in pure writing joy.  I compose the posts, I submit them, and viola!  They’re published on nice-looking sites, promoted by people with reach, and read by many (hopefully) interested readers.  Life is good.

By way of comparison, when it comes to my own blog, life is not quite so simple.  On my own blog, I have to write the posts and manage all of the details that are abstracted away when I write for other sites.  So many things distract from content.

ShakespeareWriting

There are the major ancillary concerns like the site’s look and feel and following up on any downtime or outages.  There are minor ancillary concerns, like checking for typos, promoting the posts, and making sure no one is inappropriate in the comments.  And then there are enigmatic ancillary concerns, like search engine optimization (SEO).  My primary concern is content generation, however, so, even with my own site, I seek to abstract as much of this away as possible.

The Weird World of SEO

Let me start off by saying, emphatically, that I am not an SEO expert.  Frankly, it’s not a topic that particularly interests me in and of itself… at least not until I had to be interested in it.

I have a blog as part of my website, but from that same website, I offer information about my consulting practice and about books and products that I offer.  More readers translates into more engagement, which, in turn, translates into a better living for me.  And it was against this backdrop that I became interested in SEO by default.

SEO actually reminds me of the credit score concept, in which a mysterious agency uses a mysterious algorithm to compute a score that has a serious effect on your life.  The mystery and complexity of the algorithm and proprietary nature of the score, in turn, create a cottage industry of advice and services aimed at helping you get just a little bit better.

As a blogger and entrepreneur, this is the SEO world for me.  Google (and nominally other search providers) have secret sauce algorithms that figure out how to rank content based on its likelihood of being valuable to people using the search engine.  I don’t care much about these for their own sake, but I do wind up having to learn enough about how the whole thing works in order to make (what I hope are) informed decisions on how to position myself.  Oh, and I have to do that while not wasting a whole lot of time on it and veering into the land of diminishing returns.

Read More