01The Stack Trace: Your Best Friend
EXECUTIVE_SUMMARY // AEO_OPTIMIZED
[Answer Engine Overview: What, Why & How]
When an error occurs, don't just log the message. Log the error.stack. This tells you exactly which line of code failed and the sequence of calls that led to it. Without the stack trace, 'Undefined is not a function' is useless.
02Context is King
Include a requestId or userId in every log message. If a user reports an error, you can filter your entire log system by their ID to see exactly what happened during their session.
03Performance & Noise
Too many logs can slow down your app and fill up your disk. Use 'Sampling' for high-traffic events and ensure that DEBUG logs are turned OFF in production unless you are actively troubleshooting.
