Skip to content

Commit

Permalink
make client-go log to console instead of file (#41)
Browse files Browse the repository at this point in the history
Co-authored-by: Thomas Dupas <[email protected]>
  • Loading branch information
thomasdupas and thomasdupas authored May 14, 2020
1 parent b6298fa commit af78483
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
7 changes: 7 additions & 0 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"flag"
"k8s.io/klog"
"log"
"os"
"os/signal"
Expand All @@ -20,6 +21,12 @@ func main() {
// Set logging output to standard console out
log.SetOutput(os.Stdout)

// kubernetes client-go uses klog, which logs to file by default. Change defaults to log to stderr instead of file.
klogFlags := flag.NewFlagSet("klog", flag.ExitOnError)
klog.InitFlags(klogFlags)
logtostderr := klogFlags.Lookup("logtostderr")
logtostderr.Value.Set("true")

sigs := make(chan os.Signal, 1) // Create channel to receive OS signals
stop := make(chan struct{}) // Create channel to receive stop signal

Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ require (
k8s.io/api v0.0.0-20190905160310-fb749d2f1064
k8s.io/apimachinery v0.0.0-20190831074630-461753078381
k8s.io/client-go v12.0.0+incompatible
k8s.io/klog v0.4.0
k8s.io/utils v0.0.0-20190829053155-3a4a5477acf8 // indirect
)

0 comments on commit af78483

Please sign in to comment.