Github user FSchumacher commented on a diff in the pull request: https://github.com/apache/jmeter/pull/254#discussion_r99488717 --- Diff: src/core/org/apache/jmeter/NewDriver.java --- @@ -276,4 +276,106 @@ private static String exceptionsToString(List<Exception> exceptionsInInit) { } return builder.toString(); } + + /* + * Set logging related system properties. + */ + private static void setLoggingProperties(String[] args) { + String jmLogFile = getCommandLineArgument(args, (int) 'j', "jmeterlogfile");// $NON-NLS-1$ $NON-NLS-2$ + + if (jmLogFile != null && !jmLogFile.isEmpty()) { + jmLogFile = replaceDateFormatInFileName(jmLogFile); + System.setProperty("jmeter.logfile", jmLogFile);// $NON-NLS-1$ + } else if (System.getProperty("jmeter.logfile") == null) {// $NON-NLS-1$ + System.setProperty("jmeter.logfile", "jmeter.log");// $NON-NLS-1$ $NON-NLS-2$ + } + + String jmLogConf = getCommandLineArgument(args, (int) 'i', "jmeterlogconf");// $NON-NLS-1$ $NON-NLS-2$ + File logConfFile = null; + + if (jmLogConf != null && !jmLogConf.isEmpty()) { + logConfFile = new File(jmLogConf); + } else if (System.getProperty("log4j.configurationFile") == null) {// $NON-NLS-1$ + logConfFile = new File("log4j2.xml");// $NON-NLS-1$ + if (!logConfFile.isFile()) { + logConfFile = new File(JMETER_INSTALLATION_DIRECTORY, "bin" + File.separator + "log4j2.xml");// $NON-NLS-1$ $NON-NLS-2$ + } + } + + if (logConfFile != null) { + System.setProperty("log4j.configurationFile", logConfFile.toURI().toString());// $NON-NLS-1$ + } + } + + /* + * Find command line argument option value by the id and name. + */ + private static String getCommandLineArgument(String [] args, int id, String name) { + final String shortArgName = "-" + ((char) id);// $NON-NLS-1$ + final String longArgName = "--" + name;// $NON-NLS-1$ + + String value = null; + + for (int i = 0; i < args.length; i++) { + if (shortArgName.equals(args[i]) && i < args.length - 1) { + if (!args[i + 1].startsWith("-")) {// $NON-NLS-1$ + value = args[i + 1]; + } + break; + } else if (!shortArgName.equals(args[i]) && args[i].startsWith(shortArgName)) { + value = args[i].substring(shortArgName.length()); + break; + } else if (longArgName.equals(args[i])) { + if (!args[i + 1].startsWith("-")) {// $NON-NLS-1$ + value = args[i + 1]; + } + break; + } + } + + return value; + } + + /* + * If the fileName contains at least one set of paired single-quotes, reformat using DateFormat --- End diff -- I haven't found the documentation, where the format is specified for the user. Would it be simpler to use a standard time/date formatter from the jdk instead of implementing a simple parser ourselves?
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---