-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Standard CDK log messages are written to the StandardError stream #7717
Comments
Or at least give us possibility to disable default log messages. |
@DamirAinullin - These were initially writing to the console rather than stderr/stdout and IIRC it was changed to improve the color experience (#5250) I also think it's reasonable to have a switch to turn off logging, which does not currently exist. I've been looking into alternatives to our current logging as I would like to switch off it. |
No, it just would be great to have ability not to write logs to the StandardError stream. |
A nice thing to have would be a possibility of logging to stdout/stderr and file and the same time, and having those logging levels configurable separately. See ansible/ansible#38786 |
Just another idea, if the logging system gets redesigned: it would be helpful to log json. |
@marcindulak I do want to rewrite the logging to be a little more pragmatic now that we've collected more use cases and pain points. I also think it's a reasonable short term ask to add a flag to disable it to unblock use cases as the one mentioned by @DamirAinullin |
@shivlaks do you have any updates about this issue? |
Hi all, I was struggling with this as well looks like as part of #9516 and CDK version 1.60. You can now use a environment variable "CI" set to any value. This will change the logging behavior and appears to use stdout and therefore fixes the issue with CI/CD tooling reporting back in an error state. |
@weschan I've tested that in 1.61.1 and this doesn't seem to work. It also seems to be a bad band aid. For auditing and traceability it seems desirable to see what changes are being applied. Fundamentally only errors should be written to stderr. What's the underlying reason output is written there rather than stdout? @shivlaks can this be bumped in priority? Understand this might have upstream issues, but it makes it difficult to do anything programmatically against output with CI/CD tooling while it's returning through stderr. |
I've tried the "CI" variable as @joel100 did with version 1.75.0 and it doesn't seem to work for me either (unless I'm doing something wrong). It definitely sucks having the CI/CD server thinking everything has failed, when in actual fact it's fine. Looks like you were recently assigned @rix0rrr does that mean we might see some movement soon? 🤞 |
Any update on this please? |
As of v1.125.0, even using the |
I wanted to weigh in on this one with my use case as well. I'm currently using
However, So, instead, I have to run with a
This significantly slows down our build process because info messages are output to Looking a bit more into the code that handles
I'm assuming this is why this ticket was tagged as "effort/large". In an ideal world, it feels like anything that writes out to the user via the console should go through |
Going to add our use case as well. In our TeamCity jobs, we now have to add several custom failure conditions to each job that runs any CDK. For example, we have checks for the following strings in our build logs:
Now multiply all these error conditions for each of our build and deployment jobs that use CDK. It's a maintenance problem. Contrast this to every other CLI tool: I simply check the TeamCity box that fails the build if any output is written to STDERR. This is causing false successful builds, and worse: false successful deployments. But the worst is that it's eroding trust in our build infrastructure. We can't predict all of the possible strings that indicate errors. Please, change the output to match every other CLI tool, and use the output streams as they were designed. CDK team, I really wish your reason for doing this was more than "colors". You've gone against the fundamentals and it's causing legitimate pain for your users. It seems like you're prioritizing people who build and deploy manually from their local machine, rather than the teams using CI/automation. |
The CLI currently sends almost all logs to `stderr`, even success messages. Based on the linked issue, this was done to make terminal colors easier to see. While this might make it easier for users that are running the CLI from their local machine, it causes issues on some CI systems that will exit if anything is written to `stderr` (even when the exit code is 0). This PR updates all of the logging mechanisms to recognize the `ci` argument. If `--ci` is passed, or the environment variable `CI=true` then all logs (except for error logs) will be sent to `stdout`. Currently the `ci` argument was only available on the `deploy` command, but this PR moves that to the global arguments list so that it will apply to all commands. I tested this manually on a CDK app by using a script to capture `stderr` and `stdout`. ```bash export CI=true key="$1" cmd="npx cdk deploy" errlog=$(mktemp) stdlog=$(mktemp) $cmd 1>> "$stdlog" 2> "$errlog" echo "-------------------errlog---------------------" cat "$errlog" echo "-------------------stdlog---------------------" cat "$stdlog" rm -f "$errlog" rm -f "$stdlog" ``` I also added new unit and integration tests that validate the change. fixes #7717 ---- ### All Submissions: * [x] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) ### Adding new Unconventional Dependencies: * [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md/#adding-new-unconventional-dependencies) ### New Features * [x] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md)? * [x] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)? *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
|
…20957) The CLI currently sends almost all logs to `stderr`, even success messages. Based on the linked issue, this was done to make terminal colors easier to see. While this might make it easier for users that are running the CLI from their local machine, it causes issues on some CI systems that will exit if anything is written to `stderr` (even when the exit code is 0). This PR updates all of the logging mechanisms to recognize the `ci` argument. If `--ci` is passed, or the environment variable `CI=true` then all logs (except for error logs) will be sent to `stdout`. Currently the `ci` argument was only available on the `deploy` command, but this PR moves that to the global arguments list so that it will apply to all commands. I tested this manually on a CDK app by using a script to capture `stderr` and `stdout`. ```bash export CI=true key="$1" cmd="npx cdk deploy" errlog=$(mktemp) stdlog=$(mktemp) $cmd 1>> "$stdlog" 2> "$errlog" echo "-------------------errlog---------------------" cat "$errlog" echo "-------------------stdlog---------------------" cat "$stdlog" rm -f "$errlog" rm -f "$stdlog" ``` I also added new unit and integration tests that validate the change. fixes aws#7717 ---- ### All Submissions: * [x] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) ### Adding new Unconventional Dependencies: * [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md/#adding-new-unconventional-dependencies) ### New Features * [x] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md)? * [x] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)? *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Standard default CDK log messages are written to the StandardError stream. We can't disable these log messages.
Environment
Other
These log messages lead to failure of AzureDevops Build:
I think that the problem is here:
aws-cdk/packages/aws-cdk/lib/logging.ts
Line 29 in 986e281
In my opinion it is not good practice to write some non-error logs in stderr. And on top of all that we can't disable these default log messages.
--no-color option doesn't help. Setting options --trace --verbose as false does not disable default log messages.
This is 🐛 Bug Report
The text was updated successfully, but these errors were encountered: