Bug: Logger doesn't log to vscode debug terminal
Hello,
While development, i run my code locally in vscode. But the lambda-powertools-logger doesn't log to the vscode debug terminal.
The following Code shows the Problem.
`
const logger = new Logger({ serviceName: 'MyService', logLevel: 'DEBUG' });
logger.debug('debug');
logger.warn('warn');
logger.error('error');
logger.info('info');
console.log('real logging');
console.warn('real warning');
console.info('real info');`
If i use console.log etc the Loggings are shown in the vscode debug terminal. But the logger from the powertools are not shown.
if i would add a small hack above:
//@ts-ignore
logger.console = console;
Then the loggings are shown in the debug terminal.
Expected Behavior
The Logs which are written, should be also shown in the vscode debug terminal.
Environment
- Powertools version used: 0.9.1
- Packaging format (Layers, npm): npm
- AWS Lambda function runtime: nodejs
@StefanVolkmer-WW thanks for opening the issue.
Could you please share your .vscode/launch.json or alternative clarify how you are executing the function? Would like to try to reproduce the issue.
Hello @dreamorosi
The Launch Config is the following:
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "launch",
"program": "${workspaceRoot}/index.js",
"preLaunchTask": "TypeScript->JavaScript"
}
]
}
You can reproduce it with a Standard Config. I created a Hello World Project: https://github.com/StefanV85/LambdaPowerToolsLoggerExample
Just Clone the Repository, run npm install Run the Launch Config.
Thanks for the config & sample repository, it's been really helpful.
I've looked into it and was able to reproduce the issue but I believe this is not a bug of Powertools Logger.
As you can see in this part of the Logger implementation, we output logs directly to process.stdout & process.stderr rather than simply using console.log - this change was made in #748 to have a cleaner output on AWS Lambda, which is the primary execution environment that we are targeting at the moment (see our project tenets here).
With that said, while looking at your repo I noticed that also something like process.stdout.write('something') was not showing up in the VSCode debug console. I then searched for existing issues on the VSCode repo and found this one https://github.com/microsoft/vscode/issues/19750.
In one of the comments, it is suggested to add an additional setting ("outputCapture": "std") to the Launch config like so:
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "launch",
"program": "${workspaceRoot}/index.js",
"preLaunchTask": "TypeScript->JavaScript",
"outputCapture": "std"
}
]
}
See screenshot below that shows the new config, running your code, and with all the log outputs.

I'm going to be closing the issue and remove the bug label.
⚠️ COMMENT VISIBILITY WARNING ⚠️
Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.