Skip to content

Conversation

@abhraina-aws
Copy link
Contributor

@abhraina-aws abhraina-aws commented Jul 17, 2025

Problem:

Amazon Q extension lacks persistent logging to disk, making it difficult to debug issues after they occur. Customers have no easy way to get them to us. This commit is one in a series to enable 1 click log retrieval on the IDE.

Old log on std out starting point:
image

Solution:

You can search now for 'Logging with' in the terminal and you will find the path of the log. The log is getting stored at per workspace level.

Implement RotatingLogChannel for disk-based logging

  • Add file-based logging with automatic rotation (5MB per file)
  • Maintain maximum of 4 log files to prevent disk space issues
  • Clean up log files on VS Code shutdown
  • Add comprehensive unit tests for logging functionality

File Log Sample:
image


  • Treat all work as PUBLIC. Private feature/x branches will not be squash-merged at release time.
  • Your code changes must meet the guidelines in CONTRIBUTING.md.
  • License: I confirm that my contribution is made under the terms of the Apache 2.0 license.

@abhraina-aws abhraina-aws requested a review from a team as a code owner July 17, 2025 01:41
@github-actions
Copy link

  • This pull request implements a feat or fix, so it must include a changelog entry (unless the fix is for an unreleased feature). Review the changelog guidelines.
    • Note: beta or "experiment" features that have active users should announce fixes in the changelog.
    • If this is not a feature or fix, use an appropriate type from the title guidelines. For example, telemetry-only changes should use the telemetry type.

@abhraina-aws abhraina-aws changed the title feature(amazonq): start rotating logging to disk with cleanup feat(amazonq): start rotating logging to disk with cleanup Jul 17, 2025
@abhraina-aws abhraina-aws reopened this Jul 17, 2025
@abhraina-aws abhraina-aws changed the title feat(amazonq): start rotating logging to disk with cleanup feat(amazonq): write logs to disk with rotation & cleanup Jul 17, 2025
traceServerEnabled ? 'Amazon Q Language Server' : 'Amazon Q Logs',
extensionContext,
traceServerEnabled
? vscode.window.createOutputChannel('Amazon Q Language Server', { log: true })
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we are using Amazon Q Language Server in VSC? to align with Flare?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

Copy link
Contributor Author

@abhraina-aws abhraina-aws Jul 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This where the flare logs get printed they don't get printed through flare its in the toolkit. We are just trying to maintain the functionality here so that current std out experience doesn't change while enabling the logs on disk.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh I see if the tranceServerEnabled then we print logs to VSC
That make sense!
but this is existing right? Why do we need todo add this check again?

Copy link
Contributor Author

@abhraina-aws abhraina-aws Jul 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thats not how it works currently. We print all logs to VSC currently. If the setting is on, then we just take some of the logs to a different stdout for clean separation.

When interested in writing to the disk. I am trying to maintain the same behavior so that while std out separates based on the setting. The logs keep printing to the same file regardless. Thats why the check check moved to the top.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thats not how it works currently. We print all logs to VSC currently. If the setting is on, then we just take some of the logs to a different stdout for clean separation.

Can you point me to the logic, we have today? just for context but not a blocking for this PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

packages/amazonq/src/lsp/client.ts

Sure! This file that we have open and commenting on is the logic that governs this. This is where we decide what to put where as far as LSP logs are concerned.

Copy link
Contributor

@laileni-aws laileni-aws left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this PR. As you already investigated this issue, can you please document this in the repository about types of logs and how we extract them. If not even comment works.

@abhraina-aws
Copy link
Contributor Author

Thanks for this PR. As you already investigated this issue, can you please document this in the repository about types of logs and how we extract them. If not even comment works.

Sure there are more PRs to come. Once this is done, I will write some documentation about the whole flow.

Copy link
Contributor

@laileni-aws laileni-aws left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • If there are any followUp PR's which is dependent or in progress.
  • I recommend creating a feature branch and push your changes to the feature branch and later we can bulk merge to master.
  • If you feel these PR are independent and can go to master individually with out change in functionality. Ignore this.

@abhraina-aws
Copy link
Contributor Author

Sure I have separated them sort of as small features at this time.
Which will basically be add ons. One PR is one function working in itself that can work standalone.

@abhraina-aws abhraina-aws enabled auto-merge July 17, 2025 18:08
@abhraina-aws abhraina-aws merged commit c43ff0f into aws:master Jul 17, 2025
42 of 44 checks passed
laileni-aws added a commit to laileni-aws/aws-toolkit-vscode that referenced this pull request Jul 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants