{"record":{"id":"d63c3b1246e0a2b8","repo":"apache/hadoop","slug":"setlevel-needs-three-parameters","errorCode":null,"errorMessage":"-setlevel needs three parameters","messagePattern":"-setlevel needs three parameters","errorType":"validation","errorClass":"HadoopIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/log/LogLevel.java","lineNumber":199,"sourceCode":"        throw new HadoopIllegalArgumentException(\n            \"-getlevel needs two parameters\");\n      }\n      operation = Operations.GETLEVEL;\n      hostName = args[index+1];\n      className = args[index+2];\n      return index+3;\n    }\n\n    private int parseSetLevelArgs(String[] args, int index) throws\n        HadoopIllegalArgumentException {\n      // fail if multiple operations are specified in the arguments\n      if (operation != Operations.UNKNOWN) {\n        throw new HadoopIllegalArgumentException(\n            \"Redundant -setlevel command\");\n      }\n      // check number of arguments is sufficient\n      if (index+3 >= args.length) {\n        throw new HadoopIllegalArgumentException(\n            \"-setlevel needs three parameters\");\n      }\n      operation = Operations.SETLEVEL;\n      hostName = args[index+1];\n      className = args[index+2];\n      level = args[index+3];\n      return index+4;\n    }\n\n    private int parseProtocolArgs(String[] args, int index) throws\n        HadoopIllegalArgumentException {\n      // make sure only -protocol is specified\n      if (protocol != null) {\n        throw new HadoopIllegalArgumentException(\n            \"Redundant -protocol command\");\n      }\n      // check number of arguments is sufficient\n      if (index+1 >= args.length) {","sourceCodeStart":181,"sourceCodeEnd":217,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/log/LogLevel.java#L181-L217","documentation":"-setlevel consumes exactly three following parameters: <host:port>, <classname>, and <level>. parseSetLevelArgs checks index+3 >= args.length and throws HadoopIllegalArgumentException('-setlevel needs three parameters') when the level (or classname, or both) is absent. The level string is taken verbatim (e.g. DEBUG, INFO); validation of it as a real log4j level happens server-side, not here.","triggerScenarios":"'hadoop loglevel -setlevel namenode:9870 org.apache.hadoop.ipc.Server' (level omitted); -setlevel as the last token; trailing -protocol flag positioned where the level was expected ('-setlevel h cls -protocol https' consumes '-protocol' as the level and then fails on 'https').","commonSituations":"Forgetting the new level when scripting runtime log changes; parameter order confusion; empty $LEVEL variable in automation dropping the third argument.","solutions":["Supply all three parameters in order: '-setlevel <host:port> <classname> <LEVEL>'.","Place -protocol after the three parameters, never between them.","Guard automation scripts: fail early if any of HOST/CLASS/LEVEL is unset."],"exampleFix":"# before\nhadoop loglevel -setlevel namenode:9870 org.apache.hadoop.ipc.Server\n\n# after\nhadoop loglevel -setlevel namenode:9870 org.apache.hadoop.ipc.Server DEBUG","handlingStrategy":"validation","validationCode":"int i = Arrays.asList(args).indexOf(\"-setlevel\");\nif (i >= 0 && (i + 3 >= args.length\n      || args[i+1].startsWith(\"-\") || args[i+2].startsWith(\"-\") || args[i+3].startsWith(\"-\"))) {\n  throw new HadoopIllegalArgumentException(\n      \"-setlevel needs host:port, classname, and level as the next three tokens\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Memorize the triple: host:port, classname, LEVEL — in that order.","Fail fast in automation when any of HOST/CLASS/LEVEL is empty.","Keep -protocol at the end so it is never swallowed as the level argument."],"tags":["hadoop","logging","cli","loglevel","missing-arguments"],"backgroundTag":"insufficient-cli-arguments","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}