3

I want to log only error request and retries request/response. I tried using

        cfg := dax.DefaultConfig()
        cfg.HostPorts = []string{daxConfig.URL}
        cfg.Region = daxConfig.Region
        cfg.LogLevel = aws.LogDebugWithRequestRetries | aws.LogDebugWithRequestErrors

But this doesn't log the request body or the response How to log the request and response body ?

1 Answers1

0

Create a custom logger with the any name you want I have used customErrorLogger that implements the 'aws.logger' interface. 'aws.logger' passed an argument to 'aws.NewClient' function.

type customErrorLogger struct{}

func (l customErrorLogger ) Log(args ...interface{}) {
  
}

func main() {
    sess, err := session.NewSession()
    if err != nil {
        fmt.Println("Error creating session:", err)
        return
    }

    cfg := dax.DefaultConfig()
    cfg.HostPorts = []string{daxConfig.URL}
    cfg.Region = daxConfig.Region
    cfg.LogLevel = aws.LogDebugWithRequestRetries | aws.LogDebugWithRequestErrors

    client := dax.New(sess, cfg)

   
    client.Config.Logger = customErrorLogger {}
}
Robina Mirbahar
  • 413
  • 1
  • 11