现在不忙,把自己迷糊的知识点在学习下。
log报错
log4j:ERROR Category option " 1 " not a decimal integer.
java.lang.NumberFormatException: For input string: " 1 "
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
at java.lang.Integer.parseInt(Integer.java:449)
at java.lang.Integer.parseInt(Integer.java:499)
at org.apache.log4j.helpers.PatternParser.extractPrecisionOption(PatternParser.java:109)
at org.apache.log4j.helpers.PatternParser.finalizeConverter(PatternParser.java:227)
at org.apache.log4j.helpers.PatternParser.parse(PatternParser.java:179)
at org.apache.log4j.PatternLayout.setConversionPattern(PatternLayout.java:439)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.log4j.config.PropertySetter.setProperty(PropertySetter.java:196)
at org.apache.log4j.config.PropertySetter.setProperty(PropertySetter.java:155)
at org.apache.log4j.config.PropertySetter.setProperties(PropertySetter.java:120)
at org.apache.log4j.config.PropertySetter.setProperties(PropertySetter.java:87)
at org.apache.log4j.PropertyConfigurator.parseAppender(PropertyConfigurator.java:640)
at org.apache.log4j.PropertyConfigurator.parseCategory(PropertyConfigurator.java:603)
at org.apache.log4j.PropertyConfigurator.configureRootCategory(PropertyConfigurator.java:500)
at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:406)
at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:307)
at org.apache.log4j.PropertyConfigurator.configure(PropertyConfigurator.java:315)
at Util.main(Util.java:10)
log4j:WARN custom level class [# 只输出ERROR级别以上的日志!!!] not found.
log4j:ERROR Could not find value for key log4j.appender.E
log4j:ERROR Could not instantiate appender named "E".
网上搜了下原来是 空格导致的;
log4j.properties文件中有这么一句代码:
log4j.appender.stdout.layout.ConversionPattern = %d{ABSOLUTE} %5p %c{ 1 }:%L - %m%n
就是上面用红色标记出来的小 1出了问题,把小1两边的空格去掉,OK!
再次运行正常。