Logging: Recording useful messages about what an application is doing, such as events, warnings, and errors, so that people can understand and investigate problems later.
Example
When an order fails, your code logs "Payment failed for order 10234: gateway timeout after 30s". Next morning, support searches the logs for order 10234 and finds the cause in a minute.
Log Levels
| Level | Use it for |
|---|---|
| ERROR | Something failed and needs attention |
| WARN | Something unexpected, but the app continued |
| INFO | Important normal events, such as an order placed |
| DEBUG | Detailed information for developers, usually off in production |
What to Log and What Never to Log
- Do log: what happened, an ID to trace it (order ID, user ID, request ID), and the error message.
- Don't log: passwords, OTPs, tokens, card numbers, or unnecessary personal data.
- Don't flood logs with a message for every loop iteration; important messages get lost.
Logging in Real Teams
In production, you can't pause the program with a debugger, so logs are often the only way to see what happened. Teams send logs to central tools such as the ELK stack, Splunk, Azure Monitor, or CloudWatch, and set alerts on errors as part of monitoring. Use the team's logging library rather than print statements.
Related terms
- Monitoring: uses logs and metrics to watch system health.
- Debugging: logs help you debug where breakpoints can't.
- Error Handling: good error handling logs useful details.
- Exception: exceptions should be logged with context.
Previous term: Library | Next term: Machine Learning (ML)
Related guides
- What to Do in Your First Week of an IT Internship
- DevOps Interview Questions Test
- Technical Interview Questions for Freshers
Frequently asked questions
What is logging in software?
Logging is recording messages about what an application is doing, such as events and errors, so problems can be investigated later.
What are log levels?
Categories such as ERROR, WARN, INFO, and DEBUG that show how serious a message is and let teams filter logs.
What should never be logged?
Passwords, OTPs, tokens, card numbers, and unnecessary personal data.
Why not just use print statements?
Logging libraries add timestamps and levels, can send logs to central tools, and can be switched on or off without code changes.
Explore more internship terms
The IT Internship Glossary explains 199 terms you will hear before and during your internship, with simple definitions and real examples.
Browse all 199 terms