logback.班级找不到例外



我正在尝试将DB Appender添加到我的记录配置中。这是与该问题相关的LogBack.xml文件的一部分:

<appender name="db" class="src.main.java.database.SqliteLogbackAppender">
    <connectionSource class="ch.qos.logback.core.db.DriverManagerConnectionSource">
        <driverClass>org.sqlite.JDBC</driverClass>
        <url>jdbc:sqlite:/home/db/logger.db</url>
    </connectionSource>
</appender>

问题是,我使用的是一个自定义的appender,它位于我的 scr.main.java ... etc等文件夹中,但不在 logback-classic 库中

运行应用程序时,我会收到以下错误:

    09:02:06,682 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@31:78 - ActionException in Action for tag [appender] ch.qos.logback.core.joran.spi.ActionException: ch.qos.logback.core.util.DynamicClassLoadingException: Failed to instantiate type src.main.java.database.SqliteLogbackAppender
        at ch.qos.logback.core.joran.spi.ActionException: ch.qos.logback.core.util.DynamicClassLoadingException: Failed to instantiate type src.main.java.database.SqliteLogbackAppender
        at      at ch.qos.logback.core.joran.action.AppenderAction.begin(AppenderAction.java:76)
        at      at ch.qos.logback.core.joran.spi.Interpreter.callBeginAction(Interpreter.java:269)
        at      at ch.qos.logback.core.joran.spi.Interpreter.startElement(Interpreter.java:145)
        at      at ch.qos.logback.core.joran.spi.Interpreter.startElement(Interpreter.java:128)
        at      at ch.qos.logback.core.joran.spi.EventPlayer.play(EventPlayer.java:50)
        at      at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:155)
        at      at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:142)
        at      at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:103)
        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:149)
        at      at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:124)
        at      at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:390)
        at      at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:340)
        at      at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:361)
        at      at interaction.Commander.<clinit>(Commander.java:14)
        at      at servlets.ExecuteServlet.<clinit>(ExecuteServlet.java:24)
        at      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at      at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
        at      at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at      at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
        at      at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:120)
        at      at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1041)
        at      at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:770)
        at      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:133)
        at      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
        at      at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:475)
        at      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
        at      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:80)
        at      at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:651)
        at      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
        at      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
        at      at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:498)
        at      at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
        at      at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:796)
        at      at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1374)
        at      at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
        at      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at      at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
        at      at java.lang.Thread.run(Thread.java:748)
Caused by: ch.qos.logback.core.util.DynamicClassLoadingException: Failed to instantiate type src.main.java.database.SqliteLogbackAppender
        at      at ch.qos.logback.core.util.OptionHelper.instantiateByClassNameAndParameter(OptionHelper.java:69)
        at      at ch.qos.logback.core.util.OptionHelper.instantiateByClassName(OptionHelper.java:45)
        at      at ch.qos.logback.core.util.OptionHelper.instantiateByClassName(OptionHelper.java:34)
        at      at ch.qos.logback.core.joran.action.AppenderAction.begin(AppenderAction.java:52)
        at      ... 43 common frames omitted
Caused by: java.lang.ClassNotFoundException: src.main.java.database.SqliteLogbackAppender
        at      at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1269)
        at      at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1104)
        at      at ch.qos.logback.core.util.OptionHelper.instantiateByClassNameAndParameter(OptionHelper.java:56)
        at      ... 46 common frames omitted

但是,当我在 logback.xml 配置上编写classPath时,我可以使用Intellijidea IDE接口访问文件(通过单击CTRL LEFT_MOUSE_BUTTON),所以我相信没有错别字。

问候。

请确保在XML中为您的Appender使用完全合格的类名称,包括软件包。请勿指定课程的路径。

" src.main.java.database.sqlitelogbackappender"似乎包括maven文件夹(src/main/java),因此可能不是实际的类名称。

也许您的意思是" database.sqlitelogbackappender"?

相关内容

  • 没有找到相关文章

最新更新