我没有log4j的配置文件 我直接按照老师的文件写了一个 报错

来源:4-3 应用 log4j 调试动态 SQL

慕粉3567134

2017-07-13 16:04

log4j:ERROR Could not instantiate class [org.apache.log4j.Patternlayout].

java.lang.ClassNotFoundException: org.apache.log4j.Patternlayout

at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1720)

at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1571)

at java.lang.Class.forName0(Native Method)

at java.lang.Class.forName(Class.java:190)

at org.apache.log4j.helpers.Loader.loadClass(Loader.java:198)

at org.apache.log4j.helpers.OptionConverter.instantiateByClassName(OptionConverter.java:327)

at org.apache.log4j.helpers.OptionConverter.instantiateByKey(OptionConverter.java:124)

at org.apache.log4j.PropertyConfigurator.parseAppender(PropertyConfigurator.java:797)

at org.apache.log4j.PropertyConfigurator.parseCategory(PropertyConfigurator.java:768)

at org.apache.log4j.PropertyConfigurator.configureRootCategory(PropertyConfigurator.java:648)

at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:514)

at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:580)

at org.apache.log4j.helpers.OptionConverter.selectAndConfigure(OptionConverter.java:526)

at org.apache.log4j.LogManager.<clinit>(LogManager.java:127)

at org.apache.log4j.Logger.getLogger(Logger.java:104)

at org.apache.ibatis.logging.log4j.Log4jImpl.<init>(Log4jImpl.java:32)

at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)

at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)

at java.lang.reflect.Constructor.newInstance(Constructor.java:526)

at org.apache.ibatis.logging.LogFactory.setImplementation(LogFactory.java:133)

at org.apache.ibatis.logging.LogFactory.useLog4JLogging(LogFactory.java:101)

at org.apache.ibatis.logging.LogFactory$4.run(LogFactory.java:55)

at org.apache.ibatis.logging.LogFactory.tryImplementation(LogFactory.java:123)

at org.apache.ibatis.logging.LogFactory.<clinit>(LogFactory.java:52)

at org.apache.ibatis.executor.loader.javassist.JavassistProxyFactory.<clinit>(JavassistProxyFactory.java:47)

at org.apache.ibatis.session.Configuration.<init>(Configuration.java:126)

at org.apache.ibatis.builder.xml.XMLConfigBuilder.<init>(XMLConfigBuilder.java:82)

at org.apache.ibatis.builder.xml.XMLConfigBuilder.<init>(XMLConfigBuilder.java:66)

at org.apache.ibatis.session.SqlSessionFactoryBuilder.build(SqlSessionFactoryBuilder.java:51)

at org.apache.ibatis.session.SqlSessionFactoryBuilder.build(SqlSessionFactoryBuilder.java:38)

at com.uctech.db.DBAccess.getSqlSession(DBAccess.java:32)

at com.uctech.dao.MessageDao.getMessages(MessageDao.java:24)

at com.uctech.service.MessageService.getMessages(MessageService.java:19)

at com.uctech.servlet.MessageServlet.doGet(MessageServlet.java:33)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:620)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)

at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)

at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)

at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)

at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:503)

at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)

at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)

at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)

at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)

at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:421)

at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1070)

at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:611)

at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:314)

at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)

at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)

at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)

at java.lang.Thread.run(Thread.java:744)

log4j:ERROR No layout set for the appender named [Console].



log4j.rootLogger=DEBUG,Console

log4j.appender.Console=org.apache.log4j.ConsoleAppender

log4j.appender.Console.layout=org.apache.log4j.Patternlayout

log4j.appender.Console.layout.ConversionPatten=%d [%t] %-5p [%c] - %m%n

log4j.logger.org.apache=INFO

斜体 是报错信息   粗体 是根据老师的抄的

写回答 关注

3回答

  • 慕妹4524825
    2017-11-17 09:19:36

    java.lang.ClassNotFoundException: org.apache.log4j.Patternlayout

    你应该是没有到log4j的jar包吧??重新导一次完整的

  • 慕粉3567134
    2017-07-14 13:20:49

    去掉org  再运行就报java.lang.ClassNotFoundException: org.apache.log4j.Patternlayout

    具体报错信息:

    log4j:ERROR Could not instantiate class [org.apache.log4j.Patternlayout].


    java.lang.ClassNotFoundException: org.apache.log4j.Patternlayout

    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1720)

    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1571)

    at java.lang.Class.forName0(Native Method)

    at java.lang.Class.forName(Class.java:190)

    at org.apache.log4j.helpers.Loader.loadClass(Loader.java:198)

    at org.apache.log4j.helpers.OptionConverter.instantiateByClassName(OptionConverter.java:327)

    at org.apache.log4j.helpers.OptionConverter.instantiateByKey(OptionConverter.java:124)

    at org.apache.log4j.PropertyConfigurator.parseAppender(PropertyConfigurator.java:797)

    at org.apache.log4j.PropertyConfigurator.parseCategory(PropertyConfigurator.java:768)

    at org.apache.log4j.PropertyConfigurator.configureRootCategory(PropertyConfigurator.java:648)

    at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:514)

    at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:580)

    at org.apache.log4j.helpers.OptionConverter.selectAndConfigure(OptionConverter.java:526)

    at org.apache.log4j.LogManager.<clinit>(LogManager.java:127)

    at org.apache.log4j.Logger.getLogger(Logger.java:104)

    at org.apache.ibatis.logging.log4j.Log4jImpl.<init>(Log4jImpl.java:32)

    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)

    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)

    at java.lang.reflect.Constructor.newInstance(Constructor.java:526)

    at org.apache.ibatis.logging.LogFactory.setImplementation(LogFactory.java:133)

    at org.apache.ibatis.logging.LogFactory.useLog4JLogging(LogFactory.java:101)

    at org.apache.ibatis.logging.LogFactory$4.run(LogFactory.java:55)

    at org.apache.ibatis.logging.LogFactory.tryImplementation(LogFactory.java:123)

    at org.apache.ibatis.logging.LogFactory.<clinit>(LogFactory.java:52)

    at org.apache.ibatis.executor.loader.javassist.JavassistProxyFactory.<clinit>(JavassistProxyFactory.java:47)

    at org.apache.ibatis.session.Configuration.<init>(Configuration.java:126)

    at org.apache.ibatis.builder.xml.XMLConfigBuilder.<init>(XMLConfigBuilder.java:82)

    at org.apache.ibatis.builder.xml.XMLConfigBuilder.<init>(XMLConfigBuilder.java:66)

    at org.apache.ibatis.session.SqlSessionFactoryBuilder.build(SqlSessionFactoryBuilder.java:51)

    at org.apache.ibatis.session.SqlSessionFactoryBuilder.build(SqlSessionFactoryBuilder.java:38)

    at com.uctech.db.DBAccess.getSqlSession(DBAccess.java:32)

    at com.uctech.dao.MessageDao.getMessages(MessageDao.java:20)

    at com.uctech.service.MessageService.getMessages(MessageService.java:19)

    at com.uctech.servlet.MessageServlet.doGet(MessageServlet.java:33)

    at javax.servlet.http.HttpServlet.service(HttpServlet.java:620)

    at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)

    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)

    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)

    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)

    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)

    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)

    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)

    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:503)

    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)

    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)

    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)

    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)

    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:421)

    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1070)

    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:611)

    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:314)

    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)

    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)

    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)

    at java.lang.Thread.run(Thread.java:744)

    log4j:ERROR No layout set for the appender named [Console].


    qq_慕盖茨... 回复幕布斯609...

    解决了,楼主2个单词拼写错误了

    2019-04-17 13:39:09

    共 2 条回复 >

  • 慕粉18325050281
    2017-07-13 16:24:39

    log4j.logger.org.apache=INFO这一句中的org不要

通过自动回复机器人学Mybatis---基础版

微信公众号自动回复功能学习Mybatis,基础教程加案例实战方式学习

107412 学习 · 786 问题

查看课程

相似问题