Ensure LAPI logs respect log_media (#707)

* if log_media is set to file, don't try to log to stdout

* use the log media no matter what
This commit is contained in:
Thibault "bui" Koechlin 2021-03-22 17:46:55 +01:00 committed by GitHub
parent 1f2f6c87d5
commit 6d28599efa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -52,7 +52,7 @@ func NewServer(config *csconfig.LocalApiServerCfg) (*APIServer, error) {
}
logFile := ""
if config.LogDir != "" && config.LogMedia == "file" {
if config.LogMedia == "file" {
logFile = fmt.Sprintf("%s/crowdsec_api.log", config.LogDir)
}
@ -86,7 +86,7 @@ func NewServer(config *csconfig.LocalApiServerCfg) (*APIServer, error) {
if err != nil {
return &APIServer{}, errors.Wrapf(err, "creating api access log file: %s", logFile)
}
gin.DefaultWriter = io.MultiWriter(file, os.Stdout)
gin.DefaultWriter = io.MultiWriter(file)
}
router.Use(gin.LoggerWithFormatter(func(param gin.LogFormatterParams) string {