如何使用 slf4j 记录 postgres 驱动程序消息?

2024-04-11

我在我的网络应用程序中使用 postgres db。

我在我的中添加了以下依赖项pom.xml:

    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>1.7.5</version>
    </dependency>

    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>jul-to-slf4j</artifactId>
        <version>1.7.5</version>
    </dependency>

    <dependency>
        <groupId>ch.qos.logback</groupId>
        <artifactId>logback-classic</artifactId>
        <version>1.0.13</version>
    </dependency>

在 IntelliJ Idea 控制台日志中,我看到以下文本(深红色,这意味着它是标准输出的):

Nov 17, 2013 12:32:40 PM org.apache.naming.NamingContext lookup
WARNING: Unexpected exception resolving reference
org.postgresql.util.PSQLException: пїЅпїЅпїЅпїЅпїЅ: пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ "traffic" пїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ (пїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅ)
    at org.postgresql.core.v3.ConnectionFactoryImpl.doAuthentication(ConnectionFactoryImpl.java:291)
    at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:108)
    at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:66)
    at org.postgresql.jdbc2.AbstractJdbc2Connection.<init>(AbstractJdbc2Connection.java:125)
    at org.postgresql.jdbc3.AbstractJdbc3Connection.<init>(AbstractJdbc3Connection.java:30)
    at org.postgresql.jdbc3g.AbstractJdbc3gConnection.<init>(AbstractJdbc3gConnection.java:22)
    at org.postgresql.jdbc4.AbstractJdbc4Connection.<init>(AbstractJdbc4Connection.java:30)
    at org.postgresql.jdbc4.Jdbc4Connection.<init>(Jdbc4Connection.java:24)
    at org.postgresql.Driver.makeConnection(Driver.java:393)
    at org.postgresql.Driver.connect(Driver.java:267)
    at org.apache.tomcat.jdbc.pool.PooledConnection.connectUsingDriver(PooledConnection.java:267)

    [...skipped...]

 javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1420)
    at javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:848)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:322)
    at sun.rmi.transport.Transport$1.run(Transport.java:177)
    at sun.rmi.transport.Transport$1.run(Transport.java:174)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.rmi.transport.Transport.serviceCall(Transport.java:173)
    at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:556)
    at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:811)
    at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:670)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:724)

Nov 17, 2013 12:32:40 PM org.apache.catalina.core.NamingContextListener addResource
WARNING: Failed to register in JMX: javax.naming.NamingException: пїЅпїЅпїЅпїЅпїЅ: пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ "traffic" пїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ (пїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅ)

问题是如何强制使用 slf4j 记录来自 postgres 的消息?

日志记录属性

处理程序 = org.slf4j.bridge.SLF4JBridgeHandler

日志记录文件

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <property name="destination" value="${catalina.base:-./temp}/logs/billing" />

    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
        <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
            <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
        </encoder>
    </appender>

    <appender name="ROLLING" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <file>${destination}.log</file>
        <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
            <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
        </encoder>
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <fileNamePattern>${destination}-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
            <maxHistory>30</maxHistory>
        </rollingPolicy>
        <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
            <maxFileSize>100MB</maxFileSize>
        </timeBasedFileNamingAndTriggeringPolicy>
    </appender>

    <logger name="net.kerba" level="TRACE"/>

    <logger name="org" level="INFO" />

    <root level="debug">
        <appender-ref ref="STDOUT" />
        <appender-ref ref="ROLLING" />
    </root>
</configuration>

启动项目时的完整控制台输出:

D:\opt\apache-tomcat-7.0.25\bin\catalina.bat run
[2013-11-17 12:32:31,305] Artifact billing-filter:war exploded: Server is not connected. Deploy is not available.
Using CATALINA_BASE:   "D:\home\kerb\.IntelliJIdea12\system\tomcat\Unnamed_billing-filter"
Using CATALINA_HOME:   "D:\opt\apache-tomcat-7.0.25"
Using CATALINA_TMPDIR: "D:\opt\apache-tomcat-7.0.25\temp"
Using JRE_HOME:        "C:\Program Files\Java\jdk1.7.0_40"
Using CLASSPATH:       "D:\opt\apache-tomcat-7.0.25\bin\bootstrap.jar;D:\opt\apache-tomcat-7.0.25\bin\tomcat-juli.jar"
Connected to the target VM, address: '127.0.0.1:52288', transport: 'socket'
Nov 17, 2013 12:32:32 PM org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jdk1.7.0_40\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:\Program Files (x86)\JetBrains\IntelliJ IDEA 12.1\bin\..\.\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\pgmodeler\lib;C:\Program Files (x86)\GammaTech\TumarCSP\lib;C:\Program Files (x86)\GammaTech\TumarCSP\lib64;C:\Program Files\MySQL\MySQL Server 5.1\bin;C:\Program Files\erl5.10.2\bin;C:\Program Files\SlikSvn\bin;C:\Program Files\OpenVPN\bin;C:\Program Files\TortoiseHg\;D:\opt\maven3\bin;D:\opt\instantclient_11_2;D:\opt\wget\bin;D:\opt\conemu;C:\Program Files\Far Manager;C:\Program Files\PostgreSQL\9.2\bin;C:\Program Files (x86)\cwRsync\bin;C:\Program Files\WinRAR;C:\Program Files\7-Zip;c:\program files\java\jdk1.7.0_40\jre\bin;.
Nov 17, 2013 12:32:32 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8080"]
Nov 17, 2013 12:32:32 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
Nov 17, 2013 12:32:32 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 900 ms
Nov 17, 2013 12:32:32 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Nov 17, 2013 12:32:32 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.25
Nov 17, 2013 12:32:32 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8080"]
Nov 17, 2013 12:32:32 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-bio-8009"]
Nov 17, 2013 12:32:32 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 49 ms
Connected to server
[2013-11-17 12:32:32,966] Artifact billing-filter:war exploded: Artifact is being deployed, please wait...
12:32:38,593 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback.groovy]
12:32:38,594 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback-test.xml]
12:32:38,594 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Found resource [logback.xml] at [file:/D:/projects/billing-filter/target/check2/WEB-INF/classes/logback.xml]
12:32:38,612 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - debug attribute not set
12:32:38,617 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.ConsoleAppender]
12:32:38,618 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [STDOUT]
12:32:38,662 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.rolling.RollingFileAppender]
12:32:38,662 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [ROLLING]
12:32:38,685 |-INFO in c.q.l.core.rolling.TimeBasedRollingPolicy - No compression will be used
12:32:38,686 |-INFO in c.q.l.core.rolling.TimeBasedRollingPolicy - Will use the pattern D:/home/kerb/.IntelliJIdea12/system/tomcat/Unnamed_billing-filter/logs/billing-%d{yyyy-MM-dd}.%i.log for the active file
12:32:38,688 |-INFO in c.q.l.core.rolling.DefaultTimeBasedFileNamingAndTriggeringPolicy - The date pattern is 'yyyy-MM-dd' from file name pattern 'D:/home/kerb/.IntelliJIdea12/system/tomcat/Unnamed_billing-filter/logs/billing-%d{yyyy-MM-dd}.%i.log'.
12:32:38,688 |-INFO in c.q.l.core.rolling.DefaultTimeBasedFileNamingAndTriggeringPolicy - Roll-over at midnight.
12:32:38,688 |-INFO in c.q.l.core.rolling.DefaultTimeBasedFileNamingAndTriggeringPolicy - Setting initial period to Sun Nov 17 12:25:59 ALMT 2013
12:32:38,689 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@20:107 - no applicable action for [timeBasedFileNamingAndTriggeringPolicy], current ElementPath  is [[configuration][appender][timeBasedFileNamingAndTriggeringPolicy]]
12:32:38,689 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@21:26 - no applicable action for [maxFileSize], current ElementPath  is [[configuration][appender][timeBasedFileNamingAndTriggeringPolicy][maxFileSize]]
12:32:38,690 |-INFO in ch.qos.logback.core.rolling.RollingFileAppender[ROLLING] - Active log file name: D:\home\kerb\.IntelliJIdea12\system\tomcat\Unnamed_billing-filter/logs/billing.log
12:32:38,690 |-INFO in ch.qos.logback.core.rolling.RollingFileAppender[ROLLING] - File property is set to [D:\home\kerb\.IntelliJIdea12\system\tomcat\Unnamed_billing-filter/logs/billing.log]
12:32:38,691 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [net.kerba] to TRACE
12:32:38,691 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [org] to INFO
12:32:38,691 |-INFO in ch.qos.logback.classic.joran.action.RootLoggerAction - Setting level of ROOT logger to DEBUG
12:32:38,691 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [STDOUT] to Logger[ROOT]
12:32:38,692 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [ROLLING] to Logger[ROOT]
12:32:38,692 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - End of configuration.
12:32:38,692 |-INFO in ch.qos.logback.classic.joran.JoranConfigurator@2f163915 - Registering current configuration as safe fallback point

12:32:38.697 [RMI TCP Connection(3)-127.0.0.1] WARN  o.a.tomcat.jdbc.pool.ConnectionPool - maxIdle is smaller than minIdle, setting maxIdle to: 10
Nov 17, 2013 12:32:40 PM org.apache.naming.NamingContext lookup
WARNING: Unexpected exception resolving reference
org.postgresql.util.PSQLException: пїЅпїЅпїЅпїЅпїЅ: пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ "traffic" пїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ (пїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅ)
    at org.postgresql.core.v3.ConnectionFactoryImpl.doAuthentication(ConnectionFactoryImpl.java:291)
    at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:108)

[... skipped ...]

Nov 17, 2013 12:32:40 PM org.apache.catalina.core.NamingContextListener addResource
WARNING: Failed to register in JMX: javax.naming.NamingException: пїЅпїЅпїЅпїЅпїЅ: пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ "traffic" пїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ (пїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅ)
12:32:40.211 [RMI TCP Connection(3)-127.0.0.1] INFO  o.a.c.c.C.[Catalina].[localhost].[/] - No Spring WebApplicationInitializer types detected on classpath
12:32:40.330 [RMI TCP Connection(3)-127.0.0.1] INFO  o.a.c.c.C.[Catalina].[localhost].[/] - Initializing Spring FrameworkServlet 'dispatcher'
12:32:40.330 [RMI TCP Connection(3)-127.0.0.1] INFO  o.s.web.servlet.DispatcherServlet - FrameworkServlet 'dispatcher': initialization started
12:32:40.343 [RMI TCP Connection(3)-127.0.0.1] INFO  o.s.w.c.s.XmlWebApplicationContext - Refreshing WebApplicationContext for namespace 'dispatcher-servlet': startup date [Sun Nov 17 12:32:40 ALMT 2013]; root of context hierarchy
12:32:40.361 [RMI TCP Connection(3)-127.0.0.1] INFO  o.s.b.f.xml.XmlBeanDefinitionReader - Loading XML bean definitions from ServletContext resource [/WEB-INF/dispatcher-servlet.xml]
12:32:40.631 [RMI TCP Connection(3)-127.0.0.1] INFO  o.s.b.f.s.DefaultListableBeanFactory - Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@36db4683: defining beans [searchController,informationProviderRegistry,sessionDataHolder,org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,viewResolver,org.springframework.context.annotation.ConfigurationClassPostProcessor.importAwareProcessor]; root of factory hierarchy
12:32:40.765 [RMI TCP Connection(3)-127.0.0.1] INFO  o.s.w.s.m.a.DefaultAnnotationHandlerMapping - Mapped URL path [/search/by-name] onto handler 'searchController'
12:32:40.766 [RMI TCP Connection(3)-127.0.0.1] INFO  o.s.w.s.m.a.DefaultAnnotationHandlerMapping - Mapped URL path [/search/by-name.*] onto handler 'searchController'
12:32:40.766 [RMI TCP Connection(3)-127.0.0.1] INFO  o.s.w.s.m.a.DefaultAnnotationHandlerMapping - Mapped URL path [/search/by-name/] onto handler 'searchController'
12:32:40.766 [RMI TCP Connection(3)-127.0.0.1] INFO  o.s.w.s.m.a.DefaultAnnotationHandlerMapping - Mapped URL path [/search/by-host] onto handler 'searchController'
12:32:40.766 [RMI TCP Connection(3)-127.0.0.1] INFO  o.s.w.s.m.a.DefaultAnnotationHandlerMapping - Mapped URL path [/search/by-host.*] onto handler 'searchController'
12:32:40.767 [RMI TCP Connection(3)-127.0.0.1] INFO  o.s.w.s.m.a.DefaultAnnotationHandlerMapping - Mapped URL path [/search/by-host/] onto handler 'searchController'
12:32:40.767 [RMI TCP Connection(3)-127.0.0.1] INFO  o.s.w.s.m.a.DefaultAnnotationHandlerMapping - Mapped URL path [/search/hostname-traffic-details/{uuid}] onto handler 'searchController'
12:32:40.767 [RMI TCP Connection(3)-127.0.0.1] INFO  o.s.w.s.m.a.DefaultAnnotationHandlerMapping - Mapped URL path [/search/hostname-traffic-details/{uuid}.*] onto handler 'searchController'
12:32:40.767 [RMI TCP Connection(3)-127.0.0.1] INFO  o.s.w.s.m.a.DefaultAnnotationHandlerMapping - Mapped URL path [/search/hostname-traffic-details/{uuid}/] onto handler 'searchController'
12:32:40.768 [RMI TCP Connection(3)-127.0.0.1] INFO  o.s.w.s.m.a.DefaultAnnotationHandlerMapping - Mapped URL path [/search/download/{uuid}] onto handler 'searchController'
12:32:40.768 [RMI TCP Connection(3)-127.0.0.1] INFO  o.s.w.s.m.a.DefaultAnnotationHandlerMapping - Mapped URL path [/search/download/{uuid}.*] onto handler 'searchController'
12:32:40.768 [RMI TCP Connection(3)-127.0.0.1] INFO  o.s.w.s.m.a.DefaultAnnotationHandlerMapping - Mapped URL path [/search/download/{uuid}/] onto handler 'searchController'
12:32:40.769 [RMI TCP Connection(3)-127.0.0.1] INFO  o.s.w.s.m.a.DefaultAnnotationHandlerMapping - Mapped URL path [/search] onto handler 'searchController'
12:32:40.769 [RMI TCP Connection(3)-127.0.0.1] INFO  o.s.w.s.m.a.DefaultAnnotationHandlerMapping - Mapped URL path [/search.*] onto handler 'searchController'
12:32:40.769 [RMI TCP Connection(3)-127.0.0.1] INFO  o.s.w.s.m.a.DefaultAnnotationHandlerMapping - Mapped URL path [/search/] onto handler 'searchController'
12:32:40.769 [RMI TCP Connection(3)-127.0.0.1] INFO  o.s.w.s.m.a.DefaultAnnotationHandlerMapping - Mapped URL path [/search/.*] onto handler 'searchController'
12:32:40.770 [RMI TCP Connection(3)-127.0.0.1] INFO  o.s.w.s.m.a.DefaultAnnotationHandlerMapping - Mapped URL path [/search/city/{city}] onto handler 'searchController'
12:32:40.770 [RMI TCP Connection(3)-127.0.0.1] INFO  o.s.w.s.m.a.DefaultAnnotationHandlerMapping - Mapped URL path [/search/city/{city}.*] onto handler 'searchController'
12:32:40.770 [RMI TCP Connection(3)-127.0.0.1] INFO  o.s.w.s.m.a.DefaultAnnotationHandlerMapping - Mapped URL path [/search/city/{city}/] onto handler 'searchController'
12:32:40.771 [RMI TCP Connection(3)-127.0.0.1] INFO  o.s.w.s.m.a.DefaultAnnotationHandlerMapping - Mapped URL path [/search/by-ip] onto handler 'searchController'
12:32:40.771 [RMI TCP Connection(3)-127.0.0.1] INFO  o.s.w.s.m.a.DefaultAnnotationHandlerMapping - Mapped URL path [/search/by-ip.*] onto handler 'searchController'
12:32:40.771 [RMI TCP Connection(3)-127.0.0.1] INFO  o.s.w.s.m.a.DefaultAnnotationHandlerMapping - Mapped URL path [/search/by-ip/] onto handler 'searchController'
12:32:40.771 [RMI TCP Connection(3)-127.0.0.1] INFO  o.s.w.s.m.a.DefaultAnnotationHandlerMapping - Mapped URL path [/search/ip-traffic-details/{uuid}] onto handler 'searchController'
12:32:40.772 [RMI TCP Connection(3)-127.0.0.1] INFO  o.s.w.s.m.a.DefaultAnnotationHandlerMapping - Mapped URL path [/search/ip-traffic-details/{uuid}.*] onto handler 'searchController'
12:32:40.772 [RMI TCP Connection(3)-127.0.0.1] INFO  o.s.w.s.m.a.DefaultAnnotationHandlerMapping - Mapped URL path [/search/ip-traffic-details/{uuid}/] onto handler 'searchController'
12:32:40.772 [RMI TCP Connection(3)-127.0.0.1] INFO  o.s.w.s.m.a.DefaultAnnotationHandlerMapping - Mapped URL path [/search/as-excel/{uuid}] onto handler 'searchController'
12:32:40.772 [RMI TCP Connection(3)-127.0.0.1] INFO  o.s.w.s.m.a.DefaultAnnotationHandlerMapping - Mapped URL path [/search/as-excel/{uuid}.*] onto handler 'searchController'
12:32:40.773 [RMI TCP Connection(3)-127.0.0.1] INFO  o.s.w.s.m.a.DefaultAnnotationHandlerMapping - Mapped URL path [/search/as-excel/{uuid}/] onto handler 'searchController'
12:32:41.058 [RMI TCP Connection(3)-127.0.0.1] INFO  o.s.web.servlet.DispatcherServlet - FrameworkServlet 'dispatcher': initialization completed in 728 ms
[2013-11-17 12:32:41,096] Artifact billing-filter:war exploded: Artifact is deployed successfully
12:32:42.416 [http-bio-8080-exec-1] INFO  o.a.j.compiler.TldLocationsCache - At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.

新的 Postgres 驱动程序 42.0.0 https://github.com/pgjdbc/pgjdbc使用 java.util.logging,请参阅变更日志 https://jdbc.postgresql.org/documentation/changelog.html#version_42.0.0

获取日志:

  1. Add 七月至 slf4j 桥 https://www.slf4j.org/legacy.html#jul-to-slf4j:

    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>jul-to-slf4j</artifactId>
        <version>${slf4j.version}</version>
    </dependency>
    
  2. 添加logback.xml(logback-test.xml)

    <logger name="org.postgresql" level="trace"/>
    
  3. 添加代码中

    static {
        SLF4JBridgeHandler.install();
    }
    
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

如何使用 slf4j 记录 postgres 驱动程序消息? 的相关文章

  • 从文本文件中读取阿拉伯字符

    我完成了一个项目 在该项目中我读取了用记事本编写的文本文件 我的文本文件中的字符是阿拉伯语 文件编码类型是UTF 8 当在 Netbeans 7 0 1 中启动我的项目时 一切似乎都正常 但是当我将项目构建为 jar 文件时 字符以这种方式
  • 将构造函数作为参数传递给方法

    我是java新手 开始研究构造函数 我看到一些构造函数作为参数传递给方法的示例 请告诉我当构造函数作为参数传递给方法时会发生什么 或者建议我一些链接 我可以在其中获得有关使用构造函数的足够知识 根据您需要传递构造函数的目的 您可以考虑传递供
  • 在 Java 正则表达式中获取多个模式的重叠匹配

    我有同样的问题这个链接 https stackoverflow com questions 18751486 matching one string multiple times using regex in java 但有多种模式 我的正
  • 运行 java -jar 时出现 java.lang.ClassNotFoundException

    我正在使用 ant 来构建我的build xml文件 它编译正常 但随后得到运行时java lang NoClassDefFoundError通过 运行生成的 jar 时java jar my jar jar 似乎这个问题出现了很多 但没有
  • 使用 Spring 控制器处理错误 404

    I use ExceptionHandler处理我的网络应用程序抛出的异常 在我的例子中我的应用程序返回JSON回应HTTP status用于对客户端的错误响应 但是 我正在尝试弄清楚如何处理error 404返回与处理的类似的 JSON
  • 以有效的方式从 Map 中删除多个键?

    我有一个Map
  • 在java中将字符串日期转换为美国格式

    我有下面的代码 其中日期为字符串类型 我必须将其设置为美国格式 所以下面我已经展示了它 private static final SimpleDateFormat usOutputDate new SimpleDateFormat MM d
  • 无法从资源加载图片

    So I am trying to load a image file from a resource so that when I export my application into a jar file it could be use
  • 确定序列化对象的类型

    我需要通过套接字发送消息 从用户到引擎的请求 以及从引擎到用户的响应 所以流程本质上是 serialized request Server lt network gt Client serialized response request r
  • java setFullScreenWindow 在 Mac 中隐藏登录对话框

    我使用的是全屏窗口 类似于屏幕保护程序 使用这里的方法 GraphicsEnvironment getLocalGraphicsEnvironment getDefaultScreenDevice setFullScreenWindow t
  • 具有 JPA 持久性的 Spring 状态机 - 存储库使用

    我试图弄清楚如何轻松使用 Spring 状态机 包括使用 JPA 进行持久化 这是我正在处理的问题 不兼容的数据类型 工厂和持久性 在程序的某个时刻 我想使用连接到用户的状态机 有用于此目的的存储库 项目spring statemachin
  • 在尝试使用 GPS 之前如何检查 GPS 是否已启用

    我有以下代码 但效果不好 因为有时 GPS 需要很长时间 我该如何执行以下操作 检查GPS是否启用 如果启用了 GPS 请使用 GPS 否则请使用网络提供商 如果 GPS 时间超过 30 秒 请使用网络 我可以使用时间或 Thread sl
  • JUNIT 测试 void 方法

    我有一个充满 void 方法的 java 类 我想进行一些单元测试以获得最大的代码覆盖率 例如我有这个方法 protected static void checkifValidElements int arg1 int arg2 metho
  • 在 Java 中创建 XML 文件的最佳方法是什么?

    我们目前使用 dom4j 来创建 XML 文件 不过 我猜现在有更好的东西了 如果我们使用的是 Java 1 6 或更高版本 那么在编写 XML 文件时最好使用什么类 运行速度最快 使用简单 我不需要构建一个 DOM 然后编写整个 DOM
  • 在 java 中运行外部应用程序但不要等待它完成

    我正在用java编写一个应用程序 允许我运行其他应用程序 为此 我使用了 Process 类对象 但当我这样做时 应用程序会等待进程结束 然后再退出 有没有办法在 Java 中运行外部应用程序 但不等待它完成 public static v
  • 嵌套字段的 Comparator.comparing(...)

    假设我有一个这样的域模型 class Lecture Course course getters class Course Teacher teacher int studentSize getters class Teacher int
  • 为什么无法从 WEB-INF 文件夹内加载 POSModel 文件?

    我在我的 Web 项目中使用 Spring MVC 我将模型文件放在 WEB INF 目录中 String taggerModelPath WEB INF lib en pos maxent bin String chunkerModelP
  • 决策树和规则引擎 (Drools)

    In the application that I m working on right now I need to periodically check eligibility of tens of thousands of object
  • Java中单例的其他方式[重复]

    这个问题在这里已经有答案了 只是我在考虑编写单例类的其他方法 那么这个类是否被认为是单例类呢 public class MyClass static Myclass myclass static myclass new MyClass pr
  • mybatis:使用带有 XML 配置的映射器接口作为全局参数

    我喜欢使用 XML 表示法来指定全局参数 例如连接字符串 我也喜欢 Mapper 注释 当我尝试将两者结合起来时 我得到这个例外 https stackoverflow com questions 4263832 type interfac

随机推荐

  • TEdit 中的 CapsLock 密码消息在视觉上因 VCL 样式而失败

    使用 VCL 样式时 在 TEdit 中使用密码时的 CapsLock 消息会出现错误 这是没有样式的样子 VCL 样式打开 该消息是葡萄牙语的 但我认为这不重要 在 Delphi Seattle 23 0 21418 4207 带有更新
  • 为什么Python中'=='出现在'in'之前? [复制]

    这个问题在这里已经有答案了 下面的代码输出 False 而根据 Python 操作顺序 它应该输出 True 顺序应该是 gt 而不是相反 为什么 出现在 in 之前 y 33 3 in y True Output False 现有的答案提
  • 比较两个字符串是否相等的超级快速方法

    显然 在Python中检查两个字符串是否相等你可以这样做 hello word hello world 但是 如果您要比较很长的字符串 超过 100 万个字符 怎么办 python 中是否有内置方法或任何库可以更快地完成此操作 也许利用卡普
  • 过滤器有问题

    我有课程搜索一切正常 除了 当 r gt price它返回所有课程 而不是最后搜索的课程 我需要捕获最后一个 时间 然后按它过滤价格 我怎样才能做到这一点 courses Course when r gt mainCat function
  • 用户订单(买入/卖出)的股票期权价格变化

    继这个问题生成虚构的股票期权价格变化 https stackoverflow com questions 9353938 generate a fictitious stock option price variation 我希望模拟价格变
  • MySQL 命令行中的 Unicode 转义序列

    简洁版本 可以使用哪种转义序列在命令行 mysql 中搜索 unicode 字符 长版 我正在寻找一种方法 从命令行在 mysql 中搜索包含 unicode 序列 U 200B 的记录的列 我不知道该使用哪种逃避方式 我已经尝试过并且x2
  • 让表示层(JSF)处理来自服务层(EJB)的业务异常

    更新提供的实体的 EJB 方法 使用 CMT Override SuppressWarnings unchecked public boolean update Entity entity throws OptimisticLockExce
  • 为什么 debug_backtrace() 使用这么多内存?

    当尝试跟踪 PHP 中的一些内存问题时 我注意到debug backtrace 我在日志代码中调用它 似乎使用了大量内存 在大多数情况下 以下代码会打印类似的内容0 02 MB 但在一种情况下 它会打印171 85 MB before me
  • 从 Docker 中的 Python 访问 GCP Secret Manager 中的机密 - nontsop 权限被拒绝

    我正在构建一个简单的应用程序 它将 Twilio 凭据存储在 GCP Secret Manager 中 并在需要时将其拉下 但是 我在项目资源上不断收到拒绝权限错误 403 google api core exceptions Permis
  • 浏览器用户代理样式表边距 8px

    我只是想知道网站周围的空白区域 我发现它是因为用户代理样式表 Google Chrome 而存在的 并且默认为 body 标签设置了 8px 的边距 如何解决这个问题不是问题 但我对这个余量的原因感兴趣 我搜索了它 但我只找到了将边距设置为
  • urllib2 文件名

    如果我使用 urllib2 打开文件 如下所示 remotefile urllib2 urlopen http example com somefile zip 除了解析原始 URL 之外 是否有一种简单的方法来获取文件名 编辑 将打开的文
  • FlexSlider 2 在窗口大小调整时调整大小

    我正在为基于 Twitter Bootstrap 的 WordPress 制作响应式主题 我正在使用弹性滑块 http energized danyduchaine com 主页上的幻灯片 jquery 插件 不幸的是 当我调整浏览器大小时
  • 尝试在 webdriver.io 项目中打开 allure-reports 时出现异常 java.lang.UnsatisfiedLinkError

    我有一个小型 webdriver io 项目 只是为了第一次尝试它 我现在想添加诱惑报告 但是当我尝试运行时allure open我收到以下异常 但我不知道必须在哪里解决此问题 Starting web server 2021 05 04
  • Flutter 等效 Android-Toggle-Switch

    有任何像这样的扑动小部件吗这个图书馆 https github com BelkaLab Android Toggle Switch在 android java 中
  • XIB 文件在 XCode 中像 XML 一样打开,但使用 Interface Builder 可以正确打开

    当我在 Xcode 4 中双击 StartWindow xib 文件时 它不会在集成 Interface Builder 中打开 它像 XML 文件一样打开 我可以打开所有其他 xib 文件 它们会按预期显示 我可以通过 打开方式 使用旧的
  • Cython 优化

    我正在用 Python 编写一个相当大的模拟 并希望从 Cython 获得一些额外的性能 然而 对于下面的代码 我似乎没有得到那么多 即使它包含一个相当大的循环 大约 10 万次迭代 我是否犯了一些初学者错误 或者这个循环大小是否太小而无法
  • 尝试使用 Phantom.js 生成 PDF 时 Vue.js 未渲染

    在这个带有硬编码 url 的简单示例中 我的 Vue js 组件未渲染 纯 html 被渲染 但我有组件的所有位置都显示为空白 Phantomjs 应该能与 Vue js 正常工作吗 var webPage require webpage
  • 构建 Java Swing GUI 的最佳方法?

    到目前为止 我一直在使用 Netbeans Swing GUI 生成功能为我的 java 应用程序构建 GUI 现在我已经开始在我的项目中使用 Eclipse 并放弃了 Netbeans 那么除了手动编写 GUI 的所有代码之外 还有什么其
  • ios UICollectionView 单元格之间顶部/底部分离

    我有一个集合视图 工作正常 并且我调整了 X 填充的分离 而且效果很好 但对于单元格之间的 Y 填充 似乎没有调整为无分离 这是我的布局代码 UICollectionViewFlowLayout layoutItem UICollectio
  • 如何使用 slf4j 记录 postgres 驱动程序消息?

    我在我的网络应用程序中使用 postgres db 我在我的中添加了以下依赖项pom xml