Skip to content

Conversation

liranamrani
Copy link

Problem:
When using file logging (log_file configuration), log messages written to files lack timestamps, while console output includes them. This inconsistency makes it difficult to correlate events and analyze logs when file logging is used.

The issue occurs because the MultiWriter sends logs to both console (with timestamp wrapper) and file (without timestamp wrapper) outputs.

Solution:
Wrap the file writer with the same logWriter that adds timestamps to console output. This ensures both console and file logs have identical timestamp formatting while preserving all existing functionality including log rotation.

Changes:

  • Modified logging/logging.go to wrap logFile with logWriter before adding to MultiWriter
  • Preserves log rotation, filtering, and all other existing features
  • No configuration changes required
  • Maintains same performance characteristics

Fixes timestamp inconsistency between console and file logging output.
before solution -
image
after bug fix -
image

Problem:
When using file logging (log_file configuration), log messages written
to files lack timestamps, while console output includes them. This
inconsistency makes it difficult to correlate events and analyze logs
when file logging is used.

The issue occurs because the MultiWriter sends logs to both console
(with timestamp wrapper) and file (without timestamp wrapper) outputs.

Solution:
Wrap the file writer with the same logWriter that adds timestamps to
console output. This ensures both console and file logs have identical
timestamp formatting while preserving all existing functionality
including log rotation.

Changes:
- Modified logging/logging.go to wrap logFile with logWriter before
  adding to MultiWriter
- Preserves log rotation, filtering, and all other existing features
- No configuration changes required
- Maintains same performance characteristics

Fixes timestamp inconsistency between console and file logging output.
@liranamrani liranamrani requested a review from a team as a code owner September 9, 2025 10:43
Copy link

hashicorp-cla-app bot commented Sep 9, 2025

CLA assistant check
All committers have signed the CLA.

Copy link

CLA assistant check

Thank you for your submission! We require that all contributors sign our Contributor License Agreement ("CLA") before we can accept the contribution. Read and sign the agreement

Learn more about why HashiCorp requires a CLA and what the CLA includes


Liran Amrani seems not to be a GitHub user.
You need a GitHub account to be able to sign the CLA.
If you have already a GitHub account, please add the email address used for this commit to your account.

Have you signed the CLA already but the status is still pending? Recheck it.

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.

1 participant