<!-- 输出到文件 -->
<appender name="file" class="ch.qos.logback.core.rolling.RollingFileAppender">
<!-- 日志级别过滤 -->
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>INFO</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
<!-- 日志路径/名字 -->
<file>${USER_HOME}/${FILE_NAME}.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
<!-- 超过定义大小的日志压缩 -->
<fileNamePattern>
${USER_HOME}/${byDay}/${FILE_NAME}-${byDay}-%i.log.zip
</fileNamePattern>
<minIndex>1</minIndex>
<maxIndex>10</maxIndex>
</rollingPolicy>
<triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
<maxFileSize>5MB</maxFileSize>
</triggeringPolicy>
<!-- json格式的日志
"req_id": "%X{reqId}",
"elapsed_time": "#asLong{%X{elapsedTime}}"
"tags": ["errorlog"],
"project": "v102",
"timestamp": "%date{\"yyyy-MM-dd'T'HH:mm:ss,SSSZ\"}",
"log_level": "%-5level",
"thread": "%thread",
"class_name": "%class",
"line_number": "%line",
"message": "%message",
"stack_trace": "%exception{5}"
<encoder class="net.logstash.logback.encoder.AccessEventCompositeJsonEncoder">
<providers>
<pattern>
<pattern>
"custom_constant": "123",
"tags": "one", "two",
"remote_ip": "%a",
"status_code": "%s",
"elapsed_time": "%D",
"user_agent": "%i{User-Agent}",
"accept": "%i{Accept}",
"referer": "%i{Referer}"
</pattern>
</pattern>
</providers>
</encoder>
<encoder class="net.logstash.logback.encoder.LoggingEventCompositeJsonEncoder">
<providers>
<timestamp/>
<pattern>
<pattern>
"custom_constant": "123",
"tags": ["one", "two"],
"logger": "%logger",
"level": "%level",
"thread": "%thread",
"message": "%message",
</pattern>
</pattern>
</providers>
</encoder>
<!-- 简单的文本日志输出格式
<encoder>
<pattern>
%date{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{35} - %msg%n
</pattern>
</encoder>
<!-- 日志输出的文件的格式
<layout class="ch.qos.logback.classic.PatternLayout">
<pattern>%date{yyyy-MM-dd HH:mm:ss.SSS} %-5level [%thread]%logger{56}.%method:%L -%msg%n</pattern>
</layout>
</appender>
-------------------------------------------------------------------------------------------------------
18:37:21,470 |-ERROR in net.logstash.logback.composite.accessevent.AccessEventPatternJsonProvider@17c386de - Failed to parse pattern [{
"custom_constant": "123",
"tags": "one", "two",
"remote_ip": "%a",
"status_code": "%s",
"elapsed_time": "%D",
"user_agent": "%i{User-Agent}",
"accept": "%i{Accept}",
"referer": "%i{Referer}"
}] com.fasterxml.jackson.core.JsonParseException: Unexpected character (' ' (code 12288 / 0x3000)): was expecting double-quote to start field name
at [Source: {
"custom_constant": "123",
"tags": "one", "two",
"remote_ip": "%a",
"status_code": "%s",
"elapsed_time": "%D",
"user_agent": "%i{User-Agent}",
"accept": "%i{Accept}",
"referer": "%i{Referer}"
}; line: 2, column: 2]
at com.fasterxml.jackson.core.JsonParseException: Unexpected character (' ' (code 12288 / 0x3000)): was expecting double-quote to start field name
at [Source: {
"custom_constant": "123",
"tags": "one", "two",
"remote_ip": "%a",
"status_code": "%s",
"elapsed_time": "%D",
"user_agent": "%i{User-Agent}",
"accept": "%i{Accept}",
"referer": "%i{Referer}"
}; line: 2, column: 2]
at at com.fasterxml.jackson.core.JsonParser._constructError(JsonParser.java:1702)
at at com.fasterxml.jackson.core.base.ParserMinimalBase._reportError(ParserMinimalBase.java:558)
at at com.fasterxml.jackson.core.base.ParserMinimalBase._reportUnexpectedChar(ParserMinimalBase.java:456)
at at com.fasterxml.jackson.core.json.ReaderBasedJsonParser._handleOddName(ReaderBasedJsonParser.java:1771)
at at com.fasterxml.jackson.core.json.ReaderBasedJsonParser.nextFieldName(ReaderBasedJsonParser.java:921)
at at com.fasterxml.jackson.databind.deser.std.BaseNodeDeserializer.deserializeObject(JsonNodeDeserializer.java:246)
at at com.fasterxml.jackson.databind.deser.std.JsonNodeDeserializer.deserialize(JsonNodeDeserializer.java:68)
at at com.fasterxml.jackson.databind.deser.std.JsonNodeDeserializer.deserialize(JsonNodeDeserializer.java:15)
at at com.fasterxml.jackson.databind.ObjectMapper._readValue(ObjectMapper.java:3983)
at at com.fasterxml.jackson.databind.ObjectMapper.readTree(ObjectMapper.java:2372)
at at com.fasterxml.jackson.core.JsonParser.readValueAsTree(JsonParser.java:1680)
at at net.logstash.logback.pattern.AbstractJsonPatternParser.parse(AbstractJsonPatternParser.java:413)
at at net.logstash.logback.composite.AbstractPatternJsonProvider.parse(AbstractPatternJsonProvider.java:79)
at at net.logstash.logback.composite.AbstractPatternJsonProvider.setJsonFactory(AbstractPatternJsonProvider.java:67)
at at net.logstash.logback.composite.JsonProviders.setJsonFactory(JsonProviders.java:90)
at at net.logstash.logback.composite.CompositeJsonFormatter.start(CompositeJsonFormatter.java:122)
at at net.logstash.logback.encoder.CompositeJsonEncoder.start(CompositeJsonEncoder.java:203)
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:655)
at at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.<clinit>(SpringJUnit4ClassRunner.java:96)
at at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at at java.lang.reflect.Constructor.newInstance(Unknown Source)
at at org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:104)
at at org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:86)
at at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
at at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:26)
at at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
at at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:33)
at at org.junit.internal.requests.FilterRequest.getRunner(FilterRequest.java:36)
at at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createFilteredTest(JUnit4TestLoader.java:77)
at at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createTest(JUnit4TestLoader.java:68)
at at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.loadTests(JUnit4TestLoader.java:43)
at at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:444)
at at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:678)
at at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
The character it is complaining about is unicode 0x3000, otherwise known as an IDEOGRAPHIC SPACE.
Try removing these characters from your xml config. Instead use ascii 0x20 SPACE.