There is no console
object defined in the MongoDB shell.
You'll need to use the print
and printjson
functions that are globally available.
print("Hi! I'm in your log!");
Anything printed will be emitted to the current log file. If there is no log file defined in your mongo configuration, then it will be emitted to the screen/stdout, which would allow you to pipe the results to a file if you wanted (or you might just want to use the log file generated by MongoDB).
If you had a bunch of code you were using that had console.log
, you could build a polyfill that redirected the output via a print
and printjson
.