5 Very Real Logging Struggles
Logs have been around almost as long as computers and are always at the core of applications. As SaaS, big data, and IoT applications have grown, so have their logs.
People are solving big problems and making key product decisions based on logs that are often a complete mess. Even though logging is an important part of what every developer does, it’s not a top-of-mind topic when people are talking about development best practices. In this post, I’m going to share some very real logging struggles that illustrate why many developers need to change how they log application events.
Struggle #1: Logs Serve More People Than Developers
Most developers create logs with the sole intent of debugging their own code. But once that code goes into production, multiple people in the organization are depending on those same logs:
- Support teams need logs to understand the root causes of customer problems.
- Ops teams need logs to detect issues with production environments.
- Other developers may need logs to spot interdependencies between parts of the application.
- Product managers often use logs to understand feature usage and make product decisions.
Each of these different personas look at log data with a different mindset, but the logs were created based on the developer’s thought process. This can cause big struggles for non-developers who need to extract insights and information from these logs to get their work done.
Treat the requirements of log users as another product or end-user requirement. It is important for each developer to understand all of the personas and their use cases so his or her applications emit logs that are actually helpful in giving people the insights they want on a daily basis.
Struggle #2: TL;DR
Logs are supposed to help you understand: the behavior of your application, issues with your application, application usage, and much more. But if you ask most non-developers, they will say logs are “TL;DR.” In other words, not worth investing the time to read and digest them. They are right.
Most logs are ugly. Most logs are cryptic because the developers who wrote them were much closer to them than the people who are ultimately using them. If you add these two factors together, you get an incredibly painful log reading experience. Yet way too many developers and Ops people resort to manual log scanning when they have a problem to solve.
The key is to create logs that are machine readable so they can reveal what matters to you rather than manually scanning the logs and trying interpret it.
Struggle #3: Logs Are Tough to Change
Logs are part of your code, so any changes go through the same build-test-deploy cycle that you use for your functionality. The problem is, many of the personas who use log data don’t get a chance to express their requirements or needs until long after the code has shipped and when customers are actually using the functionality. It’s painful to have to rebuild logs after the fact, especially if you’re not planning for it!
Capture requirements or user stories for logging just like you would for your core functionality. At the same time, recognize that logging can be an iterative process. Its usage is only beginning when the code ships. Your logging system should be part of your design discussions and documentation. The key is to treat logging as a feature rather than something that can be taken care of later as needed.
Struggle #4: How Much Logging Is Too Much?
A lot of developers worry about the performance impact of logging. They shouldn’t. As my colleague Jon Gifford recently showed, the hit that your application will take from logging is miniscule compared to the benefits of understanding what’s happening with your application.
Developers also worry that if they add too much data or too many metrics to their logs, they will have a hard time reading those logs. Of course, this is only a problem if you’re relying on manual scanning to find relevant data points. Log management solutions like Loggly will chew through the most verbose of logs and pull out the nuggets of insight.
When you create logs, think about machines as your readers. Don’t worry about logging too much. The last thing you want to do is say, “I should have logged that” after the fact, when your application has been down for an hour or throwing random errors.
Struggle #5: In What Format Should I Log?
When developers are struggling with logging formats, readability is once again at the forefront of their minds. Structured formats like JSON can be hard for people to read. But are people the most important readers?
Use a structured format like JSON. It’s much easier for machines to read and as a result, much easier for people to gain insight. You’ll end up with more analysis and better analysis.
Conquer Your Logging Struggles
The moral of the story is this: Always log as much as you can, and always log in the best format for machine processing.
Too often, logging struggles manifest themselves when it’s too late, after your team has been burned out solving a tough problem. By changing your mindset now, you’ll be in a position to save your team from tiresome logging struggles so they can focus on real problem solving.
Want to Learn More?
Check out this great ebook, the Pragmatic Logging Handbook, written by my smart colleague Jon Gifford. If you’re running a SaaS application, you may also enjoy my blog post series on Building SaaS for Scale.
Ready to put your new knowledge into practice? Get started with a Loggly free trial!
The Loggly and SolarWinds trademarks, service marks, and logos are the exclusive property of SolarWinds Worldwide, LLC or its affiliates. All other trademarks are the property of their respective owners.