What is an application log?
There are multiple different types of logging including system logs, server logs, garbage collector logs, and application logs.
An application log is a file that contains information about events that have occurred within a software application. Every application produces logs which hold information about what the application is doing.
What type of information is included in a log? It varies by the application. The developers of the software application control what goes into the log file, but there are some commonly included components:
- context info: Background information that provides insight into the state of the application at the time of the message
- timestamps: A specific piece of contextual information for tracking and correlating issues
- Log levels: Labels that help you calculate the level of importance for the entries in your log file. Frequently used levels include INFO, WARN, and ERROR
Why are logs important?
The main use for logs is diagnostics. Logs hold information that can help with
- debugging
- analytics
- compliance
- security
Logging Agent vs Logging Library
A logging agent is a separate service that reads logs from one location and sends them to another location. Think of it like a funnel.
Some benefits of logging agents include:
- minimal setup & config
- multi-threading & failure safety
- no code
- scalable (single agent instance can log for almost any number of applications)
- modify/update/replace agents w/o having to take down application
- format-agnostic
Some drawbacks of logging agents include:
- require interaction w/ host (not good w/ Serverless)
- requires CPU compute usage to track log files
A logging library (or logging framework) is code that you embed into your application to create and manage log events.
Some benefits of logging libraries include:
Some drawbacks of logging libraries include:
- usually synchronous (application must wait for the library to finish writing a log event before continuing)
- no failure safety (libraries only run as long as your application is running)
- not scalable (each application runs its own instance of the library)