[logback-dev] [JIRA] (LOGBACK-1314) NumberFormatException: For input string: "-"
QOS.CH (JIRA)
noreply-jira at qos.ch
Wed Jun 14 10:53:00 CEST 2017
Sankha Subhra Ghosh created LOGBACK-1314:
--------------------------------------------
Summary: NumberFormatException: For input string: "-"
Key: LOGBACK-1314
URL: https://jira.qos.ch/browse/LOGBACK-1314
Project: logback
Issue Type: Bug
Components: Joran, logback-classic
Affects Versions: 1.2.3
Environment: Development
Reporter: Sankha Subhra Ghosh
Assignee: Logback dev list
I need to print the class, method and line number in the logger. FOr that I am using the following entry:
{code:java}
<appender name="ErrorFileAppender" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${stb.log.dir}eFaktura.error.detaljert.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- daily rollover -->
<fileNamePattern>${stb.log.dir}eFaktura.error.detaljert.%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>
{code}
As you can see, my pattern is
{code:java}
%d %-5p [%X{sessionId}] [%X{userId}] %C{1}.%-M:%L] %m%n{code}
Then I am getting the following error:
{code:java}
09:31:44,119 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter at 29: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)
{code}
But if I use
{code:java}
%d %-5p [%X{sessionId}] [%X{userId}] %m%n{code}
Then there is no error.
Can someone please take a look. Here is my pom entry:
{code:java}
<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>
{code}
--
This message was sent by Atlassian JIRA
(v7.3.1#73012)
More information about the logback-dev
mailing list