Your application's logs are like a diary, recording important events, actions, or messages as they occur. When you have access to an application's logs, you can better keep track of and understand what is going on behind the scenes of your application.
This article will explain the importance of logging and give you a basic understanding of the logging types, levels, and formats.
By storing your application's logs, you keep valuable historical information about your application's processes. This can be crucial for understanding the reasons behind specific behaviors in your application. For instance, if a batch of background jobs fail to execute, examining your logs could help you identify the cause.
Your application writes logs to log files, which can be challenging to query; so it can be beneficial to use a log management tool that allows you to store, read, and query logs in real-time.
Logs are typically written to the console in stdout
when you run an application in the development environment or standard output format. You can configure your application to write logs to specific files.
Generally speaking, logs are relatively easy to understand, but to properly manage and utilize your logs, it's important to understand:
With the information from your application logs, you can better understand and re-create scenarios and avoid lengthy, expensive debugging sessions that sometimes yield no results.
There are various levels of logging severity. Note that not all logging tools will support all levels of logging.
Log Type | Description |
---|---|
Debug | Detailed information used for development and debugging. |
Info | General information about the application's execution. |
Warn | Indicates potential issues or conditions that require attention. |
Error | Captures errors and failures that occur during execution. |
Fatal | Indicates severe errors that result in application termination. |
Trace | Optional detailed logging for tracking specific code execution. |
Debug and trace log levels are used in specific scenarios during development and debugging processes:
Three types of logs are common across most programming languages and frameworks, including Ruby on Rails, Elixir, and Node.js. Each log type provides useful insights for specific tasks:
Log Type | Description | Useful For |
---|---|---|
Application Logs | Logs that record events and messages specific to an application. | Debugging and monitoring application behavior |
Error Logs | Logs that capture exceptions, errors, and issues encountered in a system. | Identifying and fixing application errors, debugging |
System Logs | Logs that capture system-level events, activities, and messages. | Server administration, troubleshooting |
The type of logs you need to investigate may vary depending on the type of problem you are trying to fix, for example:
Logs can be formatted in various ways. You may have to configure your logs to output in a specific format when sending them to a logging service.
Common log formats are:
How your log messages will look will vary depending on your chosen output format:
Log Format | Log Message |
---|---|
JSON | {"timestamp": "2022-06-02T04:17:25.783Z", "severity": "warn", "message": "message"} |
Logfmt | timestamp="2022-06-02T04:17:25.783Z" severity="warn" message="message" |
NDJSON | {"timestamp": "2022-06-02T04:17:25.783Z", "severity": "warn", "message": "message"} |
Plaintext | 2022-06-02T04:17:25.783Z [warn] message |
Syslog (RFC 5424) | <134>1 2022-06-02T04:17:25.783Z - - - [warn] message |
AppSignal Logging is a powerful log management solution that puts you in charge of your logs with amazing developer-friendly features such as:
List of supported platforms |
---|
AWS Kinesis / CloudWatch |
Clever Cloud |
Gigalixir Log Drain |
Heroku Log Drain |
HTTP |
Netlify |
Scalingo Log Drain |
Syslog |
Vector |
Vercel |
We've designed our logging feature to help you get the most out of your logs, in combination with your application's monitoring data. Gain a deeper understanding of your application's behavior without needing to become an expert in DevOps.
If you've found this article interesting, you can learn more about logging on our blog:
You can start managing your application's logs in as little as five minutes with AppSignal. If you are not yet a customer, sign up for a free trial. If you get stuck or have a question about AppSignal, our dev-to-dev support is always on hand to help!
You can learn more about AppSignal Logging on our Log management page.
AppSignal offers a 30-day free trial, no credit card is required. All features are available in all plans. Start monitoring your application in just a few clicks!