简体   繁体   English

连接到托管线程中的数据库,调试值未出现在Tomcat控制台或日志中

[英]Connection to database in a managed thread, Debug values doesn't appear in Tomcat console or logs

I am facing this trouble for a long time now without accessing the debug logs of the managed Threads in my Spring boot application when run on Tomcat. 在Tomcat上运行时,我很长时间都无法在Spring引导应用程序中访问托管线程的调试日志,因此遇到了这种麻烦。 All the logs appear when run on the Eclipse/STS. 当在Eclipse / STS上运行时,将显示所有日志。

In Tomcat logs, I can only see the main Tread Logs. 在Tomcat日志中,我只能看到主要的Tread日志。

I am connection to a database through JDBC and this is happening in a separate thread. 我通过JDBC连接到数据库,并且这是在单独的线程中发生的。 I tried to follow the log configuration documentation but none of them helps to get the debug logs of these threads. 我尝试遵循日志配置文档,但是它们都无法帮助获取这些线程的调试日志。 So I do not actually see the exact problem of what is causing the connection to fail. 因此,我实际上没有看到导致连接失败的确切问题。

Here is what I tried so far: 以下是我试过到目前为止:

  1. I tried with the following logback.xml 我尝试了以下logback.xml

     <?xml version="1.0" encoding="UTF-8"?> <configuration> <!-- <appender name="stdout" class="ch.qos.logback.core.ConsoleAppender"> <Target>System.out</Target> <encoder> <pattern>%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n</pattern> </encoder> </appender> <logger name="com.biscoind" additivity="false" level="TRACE"> <appender-ref ref="stdout" /> </logger> <root level="debug"> <appender-ref ref="stdout" /> </root> --> <include resource="org/springframework/boot/logging/logback/base.xml" /> <logger name="org.springframework.web" level="DEBUG" /> </configuration> 
  2. When that did not resolve the issue I removed this file and see if by default, if it logs all the treads. 如果这样不能解决问题,我删除了此文件,并查看默认情况下是否记录了所有踏板。 But it did not. 但事实并非如此。

  3. So, I added the following configurations to the application.properties 因此,我将以下配置添加到application.properties

     logging.level.org.springframework.web:TRACE logging.level.org.hibernate:ERROR 

    Then It seemed to me that this is only logging out the above namespaces, I again added 然后在我看来,这只是注销上述名称空间,我再次添加

     debug=true logging.level.org.springframework.web:DEBUG logging.level.org.hibernate:DEBUG 

    Tried and it did not work. 尝试,它没有工作。

  4. I added my namespaces also and tried as follwing, 我还添加了我的命名空间,并尝试如下,

     debug=true logging.level.com.mydomain:DEBUG logging.level.org.springframework.web:DEBUG logging.level.org.hibernate:DEBUG 

That did not work also, I am now confused on the what should I do with the config relative to logging to make the logs to appear for the tread executions. 那也行不通,我现在对配置相对于日志的处理方式感到困惑,以使日志出现在踏步执行中。

Irrespective of the treads, because of the property spring.jpa.show-sql=true it logs the queries that are made. 不管胎面如何,由于具有spring.jpa.show-sql=true属性,它记录进行的查询。

It was not a problem with the threads at all. 这根本不是线程的问题。 The application was working correctly in the development environment. 该应用程序在开发环境中正常工作。 The problem was in the deployment environment. 问题出在部署环境中。

It turned out to be a Java version miss-match with the jar files and the JVM version. 原来是Java版本与jar文件和JVM版本不匹配。 The jars were build using Java 8 and it was running on Java 7 JVM. 罐子是使用Java 8构建的,并且在Java 7 JVM上运行。

When the JMV was changed to Java-8. 当JMV更改为Java-8时。 It worked fine. 工作正常。 So Next time I will be more careful with the version mismatch. 因此,下次我将更加注意版本不匹配。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM