2017-06-14 19 views
0

ロガーにクラス、メソッド、行番号を出力する必要があります。NumberFormatException:入力文字列の場合: " - "ログバック

09:31:44,119 |-ERROR in [email protected]:19 - RuntimeException in Action for tag [encoder] java.lang.NumberFormatException: For input string: "-" 
at java.lang.NumberFormatException: For input string: "-" 
at at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65) 
at at java.lang.Integer.parseInt(Integer.java:572) 
at at java.lang.Integer.parseInt(Integer.java:615) 
at at ch.qos.logback.core.pattern.FormatInfo.valueOf(FormatInfo.java:73) 
at at ch.qos.logback.core.pattern.parser.Parser.T(Parser.java:136) 
at at ch.qos.logback.core.pattern.parser.Parser.E(Parser.java:96) 
at at ch.qos.logback.core.pattern.parser.Parser.Eopt(Parser.java:115) 
at at ch.qos.logback.core.pattern.parser.Parser.E(Parser.java:100) 
at at ch.qos.logback.core.pattern.parser.Parser.Eopt(Parser.java:115) 
at at ch.qos.logback.core.pattern.parser.Parser.E(Parser.java:100) 
at at ch.qos.logback.core.pattern.parser.Parser.Eopt(Parser.java:115) 
at at ch.qos.logback.core.pattern.parser.Parser.E(Parser.java:100) 
at at ch.qos.logback.core.pattern.parser.Parser.Eopt(Parser.java:115) 
at at ch.qos.logback.core.pattern.parser.Parser.E(Parser.java:100) 
at at ch.qos.logback.core.pattern.parser.Parser.Eopt(Parser.java:115) 
at at ch.qos.logback.core.pattern.parser.Parser.E(Parser.java:100) 
at at ch.qos.logback.core.pattern.parser.Parser.Eopt(Parser.java:115) 
at at ch.qos.logback.core.pattern.parser.Parser.E(Parser.java:100) 
at at ch.qos.logback.core.pattern.parser.Parser.Eopt(Parser.java:115) 
at at ch.qos.logback.core.pattern.parser.Parser.E(Parser.java:100) 
at at ch.qos.logback.core.pattern.parser.Parser.Eopt(Parser.java:115) 
at at ch.qos.logback.core.pattern.parser.Parser.E(Parser.java:100) 
at at ch.qos.logback.core.pattern.parser.Parser.parse(Parser.java:91) 
at at ch.qos.logback.core.pattern.PatternLayoutBase.start(PatternLayoutBase.java:83) 
at at ch.qos.logback.classic.encoder.PatternLayoutEncoder.start(PatternLayoutEncoder.java:28) 
at at ch.qos.logback.core.joran.action.NestedComplexPropertyIA.end(NestedComplexPropertyIA.java:161) 
at at ch.qos.logback.core.joran.spi.Interpreter.callEndAction(Interpreter.java:309) 
at at ch.qos.logback.core.joran.spi.Interpreter.endElement(Interpreter.java:193) 
at at ch.qos.logback.core.joran.spi.Interpreter.endElement(Interpreter.java:179) 
at at ch.qos.logback.core.joran.spi.EventPlayer.play(EventPlayer.java:62) 
at at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:165) 
at at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:152) 
at at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:110) 
at at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:53) 
at at ch.qos.logback.classic.util.ContextInitializer.configureByResource(ContextInitializer.java:75) 
at at ch.qos.logback.classic.util.ContextInitializer.autoConfig(ContextInitializer.java:150) 
at at org.slf4j.impl.StaticLoggerBinder.init(StaticLoggerBinder.java:84) 
at at org.slf4j.impl.StaticLoggerBinder.<clinit>(StaticLoggerBinder.java:55) 
at at org.slf4j.LoggerFactory.bind(LoggerFactory.java:150) 
at at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:124) 
at at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:412) 
at at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:357) 
at at org.apache.commons.logging.impl.SLF4JLogFactory.getInstance(SLF4JLogFactory.java:155) 
at at org.apache.commons.logging.impl.SLF4JLogFactory.getInstance(SLF4JLogFactory.java:132) 
at at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:273) 
at at org.springframework.context.support.AbstractApplicationContext.<init>(AbstractApplicationContext.java:164) 
at at org.springframework.context.support.AbstractApplicationContext.<init>(AbstractApplicationContext.java:228) 
at at org.springframework.context.support.AbstractRefreshableApplicationContext.<init>(AbstractRefreshableApplicationContext.java:89) 
at at org.springframework.context.support.AbstractRefreshableConfigApplicationContext.<init>(AbstractRefreshableConfigApplicationContext.java:58) 
at at org.springframework.context.support.AbstractXmlApplicationContext.<init>(AbstractXmlApplicationContext.java:61) 
at at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:136) 
at at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83) 

しかし、私は使用している場合:

<appender name="ErrorFileAppender" class="ch.qos.logback.core.rolling.RollingFileAppender"> 
    <file>${log.dir}error.log</file> 
    <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> 
     <!-- daily rollover --> 
     <fileNamePattern>${log.dir}error.%d{yyyy-MM-dd}.%i.log</fileNamePattern> 
     <maxHistory>3</maxHistory> 
     <!--<totalSizeCap>10MB</totalSizeCap>--> 
     <TimeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"> 
      <MaxFileSize>10MB</MaxFileSize> 
     </TimeBasedFileNamingAndTriggeringPolicy> 
    </rollingPolicy> 
    <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder"> 
     <Pattern> 
      %d %-5p [%X{sessionId}] [%X{userId}] %C{1}.%-M:%L] %m%n 
     </Pattern> 
    </encoder> 
    <!--<encoder> 
     <pattern>%d %-5p [%X{sessionId}] [%X{userId}] %C{1}.%-M:%L] %m%n</pattern> 
    </encoder>--> 
</appender> 
<root level="ERROR"> 
    <appender-ref ref="ErrorFileAppender" /> 
</root> 

あなたが見ることができるように、私のパターンは

%d %-5p [%X{sessionId}] [%X{userId}] %C{1}.%-M:%L] %m%n 

は、その後、私は次のエラーを取得しています:そのために私は次のエントリを使用しています

%d %-5p [%X{sessionId}] [%X{userId}] %m%n 

エラーがないまたは。

誰かが見てください。 %M

<dependency> 
    <groupId>org.slf4j</groupId> 
    <artifactId>jcl-over-slf4j</artifactId> 
    <version>1.7.25</version> 
</dependency> 
<dependency> 
    <groupId>org.logback-extensions</groupId> 
    <artifactId>logback-ext-spring</artifactId> 
    <version>0.1.4</version> 
</dependency> 
<dependency> 
    <groupId>ch.qos.logback</groupId> 
    <artifactId>logback-classic</artifactId> 
    <version>1.2.3</version> 
    <scope>test</scope> 
</dependency> 

答えて

0

変更%-M:ここに私のPOMエントリです。

だからあなたのパターンは次のようになります。

<Pattern> 
    %d %-5p [%X{sessionId}] [%X{userId}] %C{1}.%M:%L] %m%n 
</Pattern> 
+0

@robyこんにちは、私はすでにそれを試してみました。役立たず。:( – Sankha

関連する問題