{"record":{"id":"299fbd6c9afe6a8c","repo":"fluent/fluentd","slug":"both-of-utc-and-localtime-are-specified-use-only-299fbd","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/time.rb","lineNumber":172,"sourceCode":"      end\n\n      def configure(conf)\n        if conf.has_key?('localtime') || conf.has_key?('utc')\n          if conf.has_key?('localtime')\n            conf['localtime'] = Fluent::Config.bool_value(conf['localtime'])\n          elsif conf.has_key?('utc')\n            conf['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        super\n\n        if conf.has_key?('localtime') && conf.has_key?('utc') && !(@localtime ^ @utc)\n          raise Fluent::ConfigError, \"both of utc and localtime are specified, use only one of them\"\n        end\n\n        if conf.has_key?('time_type') and @time_type == :mixed\n          if @time_format.nil? and @time_format_fallbacks.empty?\n            raise Fluent::ConfigError, \"time_type is :mixed but time_format and time_format_fallbacks is empty.\"\n          end\n        end\n\n        Fluent::Timezone.validate!(@timezone) if @timezone\n      end\n    end\n\n    module Parser\n      def self.included(mod)\n        mod.include TimeParameters\n      end\n\n      def time_parser_create(type: @time_type, format: @time_format, timezone: @timezone, force_localtime: false)","sourceCodeStart":154,"sourceCodeEnd":190,"githubUrl":"https://github.com/fluent/fluentd/blob/dd45c6e18dc7be33b5e5a0f0767bf46307ff5626/lib/fluent/time.rb#L154-L190","documentation":"Fluent::ConfigError raised in TimeParameters#configure (lib/fluent/time.rb:172), included by parser/formatter plugins via Fluent::TimeParser::Parser mixin. It fires when the config explicitly sets BOTH localtime and utc and their boolean values agree (both true or both false, i.e. !(localtime ^ utc)). The two options are contradictory ways of choosing the clock, so fluentd refuses instead of guessing.","triggerScenarios":"A <parse> or <buffer> time section (or any plugin using time parameters) containing e.g. localtime true plus utc true, or localtime false plus utc false. Note the mixin rewrites conf['localtime'] from utc before super, so writing just utc is safe — only literal double specification trips the XOR check.","commonSituations":"Copy-pasting a parser config that had localtime and adding utc while refactoring timestamps to UTC; inheriting a default template with localtime false and then adding utc false believing it reinforces UTC; mixing tail parser settings from different documentation eras.","solutions":["Keep only one option: use utc true for UTC, or localtime true/false for local time — delete the other key","If you need a fixed non-UTC offset, use timezone +0900 instead of either flag (requires a time format)","Audit the specific plugin section named in the error's config context — the check is per-parser-section, not global"],"exampleFix":"# before\n<parse>\n  @type apache2\n  time_format %d/%b/%Y:%H:%M:%S %z\n  localtime true\n  utc true\n</parse>\n\n# after\n<parse>\n  @type apache2\n  time_format %d/%b/%Y:%H:%M:%S %z\n  utc true\n</parse>","handlingStrategy":"validation","validationCode":"# pre-validate a parser section's time options:\nkeys = %w[localtime utc]\npresent = keys.select { |k| section_vars.key?(k) }\nif present.size == 2\n  lv = Fluent::Config.bool_value(section_vars['localtime'])\n  uv = Fluent::Config.bool_value(section_vars['utc'])\n  raise 'localtime and utc must not both be set to the same boolean' if lv == uv\nend","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pick exactly one clock option per parser section: utc, localtime, or timezone+offset","Code-review time-related keys as a group when editing parser configs","fluentd --dry-run catches this before restart"],"tags":["fluentd","configuration","time","utc","localtime","parser"],"backgroundTag":"conflicting-config-options","analyzedSha":"dd45c6e18dc7be33b5e5a0f0767bf46307ff5626","analyzedAt":"2026-08-21T16:22:07.332Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}