我正在尝试将 DB appender 添加到我的 logback 配置中。这是与问题相关的 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>
问题是,我使用了一个自定义附加程序,它位于我的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配置上编写类路径时,我可以使用 IntellijIdea IDE 界面访问文件(通过单击 ctrl+left_mouse_button),所以我相信没有拼写错误。
问候。