使用jetty maven插件

时间:2018-03-03 11:48:25

标签: log4j jetty log4j2 embedded-jetty maven-jetty-plugin

我的应用程序使用log4j2,我们有两个用于生产,另一个用于开发环境。我使用maven来使用mvn clean jetty:run运行应用程序。我在pom.xml中的插件配置如下所示:

      <plugin>
        <groupId>org.eclipse.jetty</groupId>
        <artifactId>jetty-maven-plugin</artifactId>
        <version>9.4.8.v20171121</version>
        <configuration>
          <systemProperties>
            <systemProperty>
              <name>log4j.configuration</name>
              <value>${log4j-dev.location}</value>
            </systemProperty>
          </systemProperties>
        </configuration>
      </plugin>

但我的应用仍然使用log4j2.xml目录中的WEB-INF/classes而不是log4j-dev.location路径中的public void amountinwords() { string word = ConvertNumbertoWords(Convert.ToInt32(popopop.Text)); amountttiinwwords.Text = word; } public static string ConvertNumbertoWords(int number) { if (number == 0) return "ZERO"; if (number < 0) return "minus " + ConvertNumbertoWords(Math.Abs(number)); string words = ""; if ((number / 1000000000) > 0) { words += ConvertNumbertoWords(number / 1000000000) + " Billion "; number %= 1000000000; } if ((number / 10000000) > 0) { words += ConvertNumbertoWords(number / 10000000) + " Crore "; number %= 10000000; } if ((number / 1000000) > 0) { words += ConvertNumbertoWords(number / 1000000) + " MILLION "; number %= 1000000; } if ((number / 1000) > 0) { words += ConvertNumbertoWords(number / 1000) + " THOUSAND "; number %= 1000; } if ((number / 100) > 0) { words += ConvertNumbertoWords(number / 100) + " HUNDRED "; number %= 100; } if (number > 0) { if (words != "") words += "AND "; var unitsMap = new[] { "ZERO", "ONE", "TWO", "THREE", "FOUR", "FIVE", "SIX", "SEVEN", "EIGHT", "NINE", "TEN", "ELEVEN", "TWELVE", "THIRTEEN", "FOURTEEN", "FIFTEEN", "SIXTEEN", "SEVENTEEN", "EIGHTEEN", "NINETEEN" }; var tensMap = new[] { "ZERO", "TEN", "TWENTY", "THIRTY", "FORTY", "FIFTY", "SIXTY", "SEVENTY", "EIGHTY", "NINETY" }; if (number < 20) words += unitsMap[number]; else { words += tensMap[number / 10]; if ((number % 10) > 0) words += " " + unitsMap[number % 10]; } } return words; } 。有什么想法吗?

1 个答案:

答案 0 :(得分:0)

我找到了解决这个问题的方法。在webdefault.xml文件中,我必须添加以下代码:

<context-param>
  <param-name>log4jConfiguration</param-name>
  <param-value>log4j2-custom.xml</param-value>
</context-param>

希望它可以帮助那些花了一整天像我一样到处寻找的人:)