Nine tips for implementing logging in games
Games are very different from other types of mobile apps. They have very distinct technical and operational challenges which necessitate specialized logging. In this post, I’ll examine the unique challenges games face and provide nine logging tips that will help increase the uptime of your game.
How Are Games Different from Other Apps?
Unlike many other apps, games don’t provide a necessary service: They strictly provide entertainment value. Thus, to convert a new user into a long-term customer, you must continually engage them. If you succeed in engaging users, the numbers show that they do become loyal.
However, in the mobile market, many excellent games made by huge developers rule the charts and user expectations are very high, which makes it essential that the developer provide not only a fun experience but also a bug-free, uninterrupted one.
Games face certain technical rigors that other apps don’t, such as:
- Users expect beautiful graphics which create heavy drawing/rendering loads on the mobile device and a requirement for the developer to maintain a good experience at all resolutions
- Games with online features have a much higher number of transactions per session than most other types of apps. This creates intense back-end load
- Game network traffic is very spiky
- Games are often more technically complex than other apps
- Most mobile game revenue is from in-app purchases, with a large percentage of purchases made by whales, necessitating never-ending streams of new content to keep users engaged
These factors make it very hard to keep your game close to 100% uptime, but at the same time overcoming them is critical to providing an engaging experience. The following logging tips give you ways to effectively monitor your app and maximize uptime.
So Here Are Some Logging Tips to Put in Practice
1) Monitor FATAL, ERROR, and Strategic INFO Level Events
Crashes, server downtime, and software errors (even if they are non-fatal) can significantly lower your 30-day retention rates for your newest users and hurt engagement and spending among your whales and other engaged users.
When implementing logging within the components of your game, you’ll want to include data that allows you to know when these errors occur and what led to them. Logging levels are useful in identifying which sequences of events lead to errors. Common logging level conventions are as follows:
ERROR | Designates error events that might still allow the application to continue running. |
FATAL | Designates very severe error events that will presumably lead the application to abort. |
INFO | Designates informational messages that highlight the progress of the application at coarse-grained level. |
WARN | Designates potentially harmful situations. |
When instrumenting your logging, you will want to be sure to measure both ERROR and FATAL levels, but additionally you’ll want to measure crucial process steps with INFO or WARN steps so that you know what led to an error. If you have instrumented right, your output should look something like this:
2) Capture Client-Side Device Specs, OS Specs, and Screen Resolutions
There is a wide variety of mobile devices out there with a range of hardware and screen resolutions. For game developers, this means they have to contend with the possibility of some of their functionality not working properly on specific devices. It also means that they must design their assets and drawing/rendering functions to compensate for multiple resolutions, differing memory and processing power, and OS versions. Errors in assets and rendering/drawing functions are one of the most common headaches for mobile game developers, so you want to ensure that you’re capturing information about your client environments with the log messages you generate. For instance, if you’re logging in JSON (one of Loggly’s preferred formats), your message might look like this:
3) Log the Usage Patterns of Crucial Game Functionality
Logging is not meant to be your analytics platform; however, from an operations perspective, it is wise to know how users are using your system and where errors occur. Therefore, you should log key events (and metadata relevant to those events) within your game loop.
4) Send Relevant User Metadata and Gameplay Data with Your Logs
Errors can be triggered by certain event chains that some users trigger more frequently than others. Your players will be diverse, so you could have new users experiencing triggering errors in tutorials or have whales using game functionality that’s breaking frequently. Thus, when you receive a log, you want to know which kind of players you’re dealing with and the gameplay environment variables relevant to your log message that will help you determine what is happening if an error occurs.
5) Capture Response Times and Error Codes for Key Network Communication
Both client and server game functionality is central to most games’ operation. You want to be sure that you’ve set service-level agreements for the response times and error thresholds that are acceptable in these communications and set alerts for them. If you’re using HTTP or TCP, you can measure the response time metric. If you’re using UDP or an asynchronous communication model, it is wise to measure the Completion Time Metric.
6) Monitor Database Transactions
In games, users are constantly changing the state of the game world. Thus a majority or significant minority of the requests made to the server involve updating or retrieving database state. You want to make sure that you’re measuring how long your database queries are taking and how those queries are affecting your overall response times.
7) Log Third-Party Tool Integrations (Especially Ads and Payment Providers)
Most developers integrate third-party services to their games. Integrations often rely on communication with outside servers, which if delayed can cause interruption in user experience. Not all third-party integrations will need to be logged. However, you should log the following:
- Third-party services that can cause significant decreases in performance: Some integrations (rendering or networking libraries) are far more likely to slow things down than others (analytics). If you are using a service that can cause significant slowness in your client or server, log it.
- Ads: It is important to log the behavior of your ad integrations (if you have them) because they display frequent interstitial graphics and interactive components on your users’ screens. If these fail, they can cause errors or crashes. Log ad display success, ad loading time, and any error or crashes associated with ads.
- Payment providers: Monitor transaction success of any third-party payment provider you use. Along with transaction success, monitor the error codes associated with payment failure and any relevant metadata to provide information on the environment in which the transaction took place and the user who attempted it.
8) Game Launch Routines and Resource Loading
When a game launches, it often has to load a lot of new assets, game state data, and interactive components. Issues at this point can cause games to either load slowly or crash completely, so you want to be measuring the times it takes your primary resources to load and be sure to capture any exceptions that occur.
9) Examine Logs Before and After Releases
After your releases, you want to measure your key data points to see if there have been any negative changes, or if you are applying a fix, to ensure it’s been successful.
Getting Started
When live games start seeing heavy growth of active users, operational challenges can overwhelm you if you’re not ready. With good logging tools and good game-specific logging practices in place, you will be much better equipped to support this growth.
Loggly has a free trial. If you’re already an experienced game programmer or live operations professional, you can get started immediately. You may also want to check out our Corona SDK and Unity integration tutorials now.
Mike Turner is a partner in Charmed Matter Games, a full pipeline a small development studio founded by several veteran online & mobile online game developers and operators. He has been developing and operating MMO, social & mobile games of varying genres since 2006 and has a large depth of experience in what makes online games sustainable & profitable. He also is well aware of what can kill games and the companies behind them and seeks to educate people how to avoid those mistakes and achieve success. Follow him on twitter: @socialgamesguy
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.
Mike Turner