{"record":{"id":"a08f541df9bb4e3d","repo":"fluent/fluentd","slug":"both-of-utc-and-localtime-are-specified-use-only","errorCode":null,"errorMessage":"both of utc and localtime are specified, use only one of them","messagePattern":"both of utc and localtime are specified, use only one of them","errorType":"exception","errorClass":"Fluent::ConfigError","httpStatus":null,"severity":"error","filePath":"lib/fluent/compat/formatter_utils.rb","lineNumber":52,"sourceCode":"\n        inject_params = {}\n        INJECT_PARAMS.each do |older, newer|\n          next unless newer\n          if conf.has_key?(older)\n            inject_params[newer] = conf[older]\n          end\n        end\n\n        if conf.has_key?('include_time_key') && Fluent::Config.bool_value(conf['include_time_key'])\n          inject_params['time_key'] ||= 'time'\n          inject_params['time_type'] ||= 'string'\n        end\n        if conf.has_key?('time_as_epoch') && Fluent::Config.bool_value(conf['time_as_epoch'])\n          inject_params['time_type'] = 'unixtime'\n        end\n        if conf.has_key?('localtime') || conf.has_key?('utc')\n          if conf.has_key?('localtime') && conf.has_key?('utc')\n            raise Fluent::ConfigError, \"both of utc and localtime are specified, use only one of them\"\n          elsif conf.has_key?('localtime')\n            inject_params['localtime'] = Fluent::Config.bool_value(conf['localtime'])\n          elsif conf.has_key?('utc')\n            inject_params['localtime'] = !(Fluent::Config.bool_value(conf['utc']))\n            # Specifying \"localtime false\" means using UTC in TimeFormatter\n            # And specifying \"utc\" is different from specifying \"timezone +0000\"(it's not always UTC).\n            # There are difference between \"Z\" and \"+0000\" in timezone formatting.\n            # TODO: add kwargs to TimeFormatter to specify \"using localtime\", \"using UTC\" or \"using specified timezone\" in more explicit way\n          end\n        end\n\n        if conf.has_key?('include_tag_key') && Fluent::Config.bool_value(conf['include_tag_key'])\n          inject_params['tag_key'] ||= 'tag'\n        end\n\n        unless inject_params.empty?\n          conf.elements << Fluent::Config::Element.new('inject', '', inject_params, [])\n        end","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/fluent/fluentd/blob/dd45c6e18dc7be33b5e5a0f0767bf46307ff5626/lib/fluent/compat/formatter_utils.rb#L34-L70","documentation":"Raised as Fluent::ConfigError by FormatterUtils.convert_formatter_conf, which translates old-style formatter/output options (include_time_key, time_as_epoch, localtime, utc, ...) into v1 inject parameters for v0.12-compat plugins. The check is on key presence, not values: if the conf contains BOTH 'localtime' and 'utc' keys it raises immediately, because 'utc' maps to localtime=false and the two contradict each other.","triggerScenarios":"A section containing 'localtime true' together with 'utc true'; even 'localtime false' + 'utc false' raises because both keys exist; configs assembled by merging snippets where each side contributed one of the flags.","commonSituations":"Copying a time-formatting block from docs into a config that already set localtime; templating systems merging user overrides with defaults; v0.12-era configs where both flags were historically tolerated.","solutions":["Keep exactly one of the two keys in that section","For UTC use 'utc true' alone (or 'timezone UTC'); for local time use 'localtime true' or omit both","Audit generated configs for simultaneous localtime/utc keys before deploy"],"exampleFix":"# before\n<match app.**>\n  @type legacy_compat_output\n  utc true\n  localtime false\n</match>\n\n# after\n<match app.**>\n  @type legacy_compat_output\n  utc true\n</match>","handlingStrategy":"validation","validationCode":"if conf.has_key?('localtime') && conf.has_key?('utc')\n  abort 'config sets both localtime and utc - keep exactly one'\nend","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep one timezone flag per section; prefer 'timezone' (e.g. timezone Asia/Tokyo) for clarity","Lint generated configs for simultaneous localtime/utc keys","Remember the check is key-presence based: localtime false + utc true still fails"],"tags":["fluentd","config","timezone","conflicting-options","v012-compat"],"backgroundTag":"conflicting-config-options","analyzedSha":"dd45c6e18dc7be33b5e5a0f0767bf46307ff5626","analyzedAt":"2026-08-21T16:22:07.332Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}