Fastify logging works differently from console.log()
. It has a few gotchas.
- If you want to log an error, it must be the first argument, and not a property inside an object. You may add your own string message as the second argument (optional but recommended).
- If you want to log an object, then put the object as the first argument, and again an optional message string as the second argument.
- But beware: If the "object" you are logging is actually a string, then do not put it as the first variable. Either wrap it inside an object, or concatenate it into your message.