logback报错,请大家帮一下忙

```<?xml version="1.0" encoding="UTF-8"?>

<!-- 定义参数常量 -->
<!-- TRACE



value="%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg %n" />

<!--控制台设置  -->
<appender name="consoleAppender" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
  <pattern>${log.pattern}</pattern>
</encoder>
</appender>
<!-- DEBUG -->
<appender name="debugAppender" class="ch.qos.logback.core.rolling.RollingFileAppender">
  <!-- 文件路径 -->
  <file>${log.filePath}/debug.log</file>
  <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
    <!-- 文件名称 -->
    <fileNamePattern>
    ${log.filePath}/debug/debug.%d{yyyy-MM-dd}.log.gz
    </fileNamePattern>
    <!-- 文件最大保存历史数量 -->
    <maxHistory>${log.maxHistory}</maxHistory>
  </rollingPolicy>
  <encoder> <pattern>${log.pattern></pattern></encoder>
  <filter class="ch.qos.logback.classic.filter.LevelFilter">
    <level>DEBUG</level>
    <onMatch>ACCEPT</onMatch>
    <onMismatch>DENY</onMismatch>
  </filter>
  </appender>
<!--INFO -->
<appender name="infoAppender" class="ch.qos.logback.core.rolling.RollingFileAppender">
  <!-- 文件路径 -->
  <file>${log.filePath}/debug.log</file>
  <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
    <!-- 文件名称 -->
    <fileNamePattern>
    ${log.filePath}/info/info.%d{yyyy-MM-dd}.log.gz
    </fileNamePattern>
    <!-- 文件最大保存历史数量 -->
    <maxHistory>${log.maxHistory}</maxHistory>
  </rollingPolicy>
  <encoder> <pattern>${log.pattern></pattern></encoder>
  <filter class="ch.qos.logback.classic.filter.LevelFilter">
    <level>INFO</level>
    <onMatch>ACCEPT</onMatch>
    <onMismatch>DENY</onMismatch>
  </filter>
  </appender>
  <!--ERROR -->
<appender name="errorAppender" class="ch.qos.logback.core.rolling.RollingFileAppender">
  <!-- 文件路径 -->
  <file>${log.filePath}/debug.log</file>
  <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
    <!-- 文件名称 -->
    <fileNamePattern>
    ${log.filePath}/error/error.%d{yyyy-MM-dd}.log.gz
    </fileNamePattern>
    <!-- 文件最大保存历史数量 -->
    <maxHistory>${log.maxHistory}</maxHistory>
  </rollingPolicy>
  <encoder> <pattern>${log.pattern></pattern></encoder>
  <filter class="ch.qos.logback.classic.filter.LevelFilter">
    <level>ERROR</level>
    <onMatch>ACCEPT</onMatch>
    <onMismatch>DENY</onMismatch>
  </filter>
  </appender>
  <logger name="com.imooc.o2o" level="${log.level}" additivity="true" >
    <appender-ref ref="debugAppender"/>
    <appender-ref ref="infoAppender"/>
    <appender-ref ref="errorAppender"/>
  </logger>
  <root level ="info">
  <appender-ref ref="consoleAppender"/>
  </root>


package com.imooc.o2o.web.superadmin;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.imooc.o2o.entity.Area;
import com.imooc.o2o.service.AreaService;


@Controller
@RequestMapping("/superadmin")
public class AreaController {
    Logger logger =LoggerFactory.getLogger(AreaController.class);
    @Autowired
    private AreaService areaService;
    @RequestMapping(value="/listarea",method = RequestMethod.GET)
    @ResponseBody
    private Map<String,Object> listArea(){
        logger.info("===start===");
        long startTime = System.currentTimeMillis();
        Map<String,Object> modelMap=new HashMap<String,Object>();
        List<Area> list = new ArrayList<Area>();
        try {
            list = areaService.getAreaList();
            modelMap.put("rows", list);
            modelMap.put("total", list.size());
        }catch(Exception e) {
            e.printStackTrace();
            modelMap.put("success",false);
            modelMap.put("errMsg",e.toString());
        }
        logger.error("test error!");
        long endTime = System.currentTimeMillis();
        logger.debug("costTime:[{}ms]",endTime-startTime);
        logger.info("===end===");
        return modelMap;
    }

}
测试的时候出现这样的异常:Failed to instantiate [ch.qos.logback.classic.LoggerContext]
Reported exception:
java.lang.IllegalArgumentException: All tokens consumed but was expecting "}"
    at ch.qos.logback.core.subst.Parser.expectNotNull(Parser.java:143)
    at ch.qos.logback.core.subst.Parser.expectCurlyRight(Parser.java:148)
    at ch.qos.logback.core.subst.Parser.T(Parser.java:94)
    at ch.qos.logback.core.subst.Parser.E(Parser.java:51)
    at ch.qos.logback.core.subst.Parser.parse(Parser.java:47)
    at ch.qos.logback.core.subst.NodeToStringTransformer.tokenizeAndParseString(NodeToStringTransformer.java:55)
    at ch.qos.logback.core.subst.NodeToStringTransformer.substituteVariable(NodeToStringTransformer.java:46)
    at ch.qos.logback.core.util.OptionHelper.substVars(OptionHelper.java:112)
    at ch.qos.logback.core.joran.spi.InterpretationContext.subst(InterpretationContext.java:157)
    at ch.qos.logback.core.joran.action.NestedBasicPropertyIA.body(NestedBasicPropertyIA.java:90)
    at ch.qos.logback.core.joran.spi.Interpreter.callBodyAction(Interpreter.java:289)
    at ch.qos.logback.core.joran.spi.Interpreter.characters(Interpreter.java:172)
    at ch.qos.logback.core.joran.spi.EventPlayer.play(EventPlayer.java:57)
    at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:165)
    at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:152)
    at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:110)
    at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:53)
    at ch.qos.logback.classic.util.ContextInitializer.configureByResource(ContextInitializer.java:82)
    at ch.qos.logback.classic.util.ContextInitializer.autoConfig(ContextInitializer.java:157)
    at ch.qos.logback.classic.spi.LogbackServiceProvider.initializeLoggerContext(LogbackServiceProvider.java:49)
    at ch.qos.logback.classic.spi.LogbackServiceProvider.initialize(LogbackServiceProvider.java:40)
    at org.slf4j.LoggerFactory.bind(LoggerFactory.java:153)
    at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:141)
    at org.slf4j.LoggerFactory.getProvider(LoggerFactory.java:419)
    at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:405)
    请问一下各位这是什么原因,本人小白,完全是照着视频里面打的

2个回答

问题解决了,初学者太过于依赖视频中的内容了,昨天找了很多logback的文章看了看,重新写了一下配置文件,终于成功了。

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问