diff --git a/cli/serve.go b/cli/serve.go index 6ace56f3d8..299d6e6daa 100644 --- a/cli/serve.go +++ b/cli/serve.go @@ -47,15 +47,19 @@ binary (which you're executing right now). Use the options below to customize the way that the kolide server works. `, Run: func(cmd *cobra.Command, args []string) { - var ( - ctx = context.Background() - logger kitlog.Logger - ) - + ctx := context.Background() config := configManager.LoadConfig() - logger = kitlog.NewLogfmtLogger(os.Stderr) - logger = kitlog.NewContext(logger).With("ts", kitlog.DefaultTimestampUTC) + var logger kitlog.Logger + { + output := os.Stderr + if config.Logging.JSON { + logger = kitlog.NewJSONLogger(output) + } else { + logger = kitlog.NewLogfmtLogger(output) + } + logger = kitlog.NewContext(logger).With("ts", kitlog.DefaultTimestampUTC) + } var ds kolide.Datastore var err error diff --git a/server/config/config.go b/server/config/config.go index a664c03990..e2e4bc1ad8 100644 --- a/server/config/config.go +++ b/server/config/config.go @@ -68,6 +68,7 @@ type OsqueryConfig struct { // LoggingConfig defines configs related to logging type LoggingConfig struct { Debug bool + JSON bool DisableBanner bool } @@ -129,6 +130,7 @@ func (man Manager) addConfigs() { // Logging man.addConfigBool("logging.debug", false) + man.addConfigBool("logging.json", false) man.addConfigBool("logging.disable_banner", false) } @@ -177,6 +179,7 @@ func (man Manager) LoadConfig() KolideConfig { }, Logging: LoggingConfig{ Debug: man.getConfigBool("logging.debug"), + JSON: man.getConfigBool("logging.json"), DisableBanner: man.getConfigBool("logging.disable_banner"), }, }