I'm currently working on a NestJS application and running into an issue with the console.log function. No matter what I input, I keep getting this error:
[Nest] 71101 - 04/03/2023, 2:14:45 PM ERROR [ExceptionsHandler] Cannot read properties of undefined (reading 'log')
Even something as simple as console.log("OK");
triggers the error.
I'm unsure of the potential causes for this problem and would like guidance on how to debug it.
The code surrounding the console.log call is minimal. Even when placed at the beginning of a function, the error persists. Although I have a Winston logger set up in my code, it's not being utilized in this service:
var winston = require('winston');
var config = {
host: '',
port: 2,
timeout: 3.0,
requireAckResponse: false,
};
var fluentTransport = require('fluent-logger').support.winstonTransport();
var fluent = new fluentTransport('docker_logs', config);
const logger = winston.createLogger({
level: 'verbose',
format: winston.format.json(),
defaultMeta: { service: 'service' },
transports: [
fluent,
],
});
export default logger;