Register custom logger before it gets used
@@ -140,6 +140,13 @@ func init() {
MaxRollCount: DEFAULT_MAX_ROLL_COUNT,
}
+ if err := seelog.RegisterCustomFormatter("EcsAgentLogfmt", logfmtFormatter); err != nil {
+ seelog.Error(err)
+ }
+ if err := seelog.RegisterCustomFormatter("EcsAgentJson", jsonFormatter); err != nil {
+ seelog.Error(err)
+ }
+
SetLevel(os.Getenv(LOGLEVEL_ENV_VAR))
if RolloverType := os.Getenv(LOG_ROLLOVER_TYPE_ENV_VAR); RolloverType != "" {
Config.RolloverType = RolloverType
@@ -164,13 +171,6 @@ func init() {
}
}
- if err := seelog.RegisterCustomFormatter("EcsAgentLogfmt", logfmtFormatter); err != nil {
- seelog.Error(err)
- }
- if err := seelog.RegisterCustomFormatter("EcsAgentJson", jsonFormatter); err != nil {
- seelog.Error(err)
- }
-
registerPlatformLogger()
reloadConfig()
}
