Stdout logging #9120
Replies: 1 comment 9 replies
-
|
Good news! Velero already implements multi-output logging for backup operations. After investigating the codebase, I found that backup logs are written to both stdout and a compressed file simultaneously. Current ImplementationVelero uses a 1. DualModeLogger CreationThe logger is created with velero/pkg/util/logging/dual_mode_logger.go Lines 47 to 68 in bd3aa00 // NewTempFileLogger creates a DualModeLogger instance that writes logs to both Stdout and a file
func NewTempFileLogger(logLevel logrus.Level, logFormat Format, hook *LogHook, fields logrus.Fields) (DualModeLogger, error) {
// ...
logger := DefaultLogger(logLevel, logFormat)
logger.Out = io.MultiWriter(os.Stdout, w) // w is a gzip writer
// ...
}2. Backup Controller UsageThe backup controller creates this dual-mode logger for each backup operation: velero/pkg/controller/backup_controller.go Lines 676 to 684 in bd3aa00 // Log the backup to both a backup log file and to stdout
backupLog, err := logging.NewTempFileLogger(b.backupLogLevel, b.formatFlag, logCounter, logrus.Fields{constant.ControllerBackup: kubeutil.NamespaceAndName(backup)})3. Log PersistenceAfter the backup completes, the compressed log file is uploaded to object storage: velero/pkg/persistence/object_store.go Lines 249 to 254 in bd3aa00 Accessing Backup Logs in StdoutThe backup logs are already being sent to stdout during backup execution. You can access them through: # View Velero pod logs
kubectl logs -n velero deployment/velero
# Follow logs in real-time during a backup
kubectl logs -n velero deployment/velero -fThese logs can be ingested by your logging infrastructure (CloudWatch, ELK, Grafana) using standard Kubernetes log collection methods. Configuration OptionsYou can configure logging behavior using Velero server flags:
Example: velero server --log-level=debug --log-format=jsonWhat You'll See in StdoutDuring a backup, you'll see entries like:
If you're not seeing backup logs in stdout, please check:
The multi-output logging is built into Velero's core backup process, so no additional configuration is needed to get logs to stdout. Let me know if you need help troubleshooting why the logs might not be appearing in your logging system! |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Right now the logs specific to my backup get compressed and stored alongside it. Is there any way I can get those logs output to stdout also (or instead)?
I really want to be able to ingest them into other logging tools like Cloudwatch/ELK/Grafana etc.
Beta Was this translation helpful? Give feedback.
All reactions