3 Types of Server Logs and Why You Need Them

·

When developing an application or website, we use logs to help us find issues in the code, or simply make sure that everything is working as planned. But a log’s benefits don’t end when an app is finished, far from it… Today I will briefly discuss three types of logs that can exist in an…

3 Types of Logs

Designing for screenprinting is a nuanced art that requires a delicate balance between creativity and technical precision. To ensure your designs come to life vibrantly and accurately on fabric, it’s crucial to consider several key factors throughout the design process.

First and foremost, vector graphics serve as the foundation for successful screenprinted designs. Vector-based graphics, created using programs like Adobe Illustrator, retain their crispness and clarity regardless of size. This is essential for screenprinting, as it guarantees sharp, clean lines that will reproduce faithfully onto fabric.

When developing an application or website, we use logs to help us find issues in the code, or simply make sure that everything is working as planned. But a log’s benefits don’t end when an app is finished, far from it…

Today I will briefly discuss three types of logs that can exist in an application and what each one is for. I’ll elaborate a bit on the benefits of each and why you would choose one over the other.

3 Types of Server Logs

  • Real-time (console)
  • Locally-stored (database)
  • Third-party logging services

Real-time logs

A real-time log is the most common type of logging developers do on a regular basis. For real-time logs, you write a simple line of code that essentially “prints” a message in the server’s console.

In the following example:

console.log("Error fetching data for user.");

It would print the message in the server or application’s console, and would look something like this:

$ 
Error fetching data for user.

This is a simple and inelegant way to look at what is happening in real-time. You can, of course, add parameters to the log’s output and get more detailed information, but essentially you only work with text.

Real-time logging is recommended for quick checks while you are programming, though it is not recommended for a production environment, as none of this output is saved by default. Also, in a production environment, there may be thousands of transactions happening at a time, and searching through a console-based log is impractical.

Locally-stored logs

You can take your logs a step higher and store them either in a filesystem or in a database. Storing logs in a database might be a better option for scalability, as you could store additional fields separately to provide context to your logs.

For instance, you might want to store the exact date/time when something occurred, the problematic line of code, the error that was thrown, the function running said code and even a stack trace of where this function was called from.

This way, if you ever want to run a search/filter operation on the logs to find a specific type of issue, time or date, you can simply run a query on your database. You may also use a reporting tool or create your own dashboard to handle these queries.

Third-party logging services

If you want to get as much data as possible and keep your codebase clean, I recommend using a third-party logging service like Sentry.io or LogRocket.

Logging services allow you to focus your energy on crafting the perfect application, without having to worry about how a log works. Logging to these services is as simple as writing one line of code (just like the real-time logs), and after that, all the information you need is at your fingerprints in their dashboard.

Sentry.io Dashboard

As you can see from the image above, services like Sentry.io provide you, not only with the error itself but a wealth of information about the situation that caused the error. You get the line of code, the function, the stack trace (in a clickable dynamic environment), and even the version of the code that has the problem.

Their dashboards allow you and your team to keep track of the issues that arise (both in development and in production) and mark them as fixed when they are ready.

LogRocket Features

And, both of these tools (Sentry and LogRocket) have free versions that allow you to use them and test them for your projects.

Conclusion

There are plenty of ways to keep track of what is going on inside your application. Sometimes you’ll need it for programming, other times for debugging. But one thing is for certain: you need to keep logs!

If you don’t keep logs, you’ll lose visibility of what is truly going on behind the scenes, and finding a bug will be a costly and frustrating endeavor.

More recent articles

  • Using Design Systems on WordPress – A Chat with Mike McAlister

    Using Design Systems on WordPress – A Chat with Mike McAlister

  • Royalties and Collaborations on WordPress – A chat with Alex Standiford from Siren Affiliates

    Royalties and Collaborations on WordPress – A chat with Alex Standiford from Siren Affiliates

  • Are You Compliant? What You Need To Make Your Policies Valid

    Are You Compliant? What You Need To Make Your Policies Valid