我正在使用带有rabbitmq的spring-amqp来交换我的应用程序中的消息。 一旦我的应用程序开始,我将在我的tomcat控制台中看到大量的消息传递监听日志。我想禁用。怎么做?
11:01:47.862 [SimpleAsyncTaskExecutor-1] DEBUG o.s.a.r.l.BlockingQueueConsumer - 检索消费者的递送: tags = [{amq.ctag-NzonI8Ja7yjfWuLGLsi4pA = job.queue}],channel = Cached Rabbit Channel:AMQChannel(amqp://BipUser@10.165.18.29:5672 /,1),conn: Proxy @ 64583ac5 Shared Rabbit Connection:SimpleConnection @ 61e800fb [delegate = amqp://BipUser@10.165.18.29:5672 /,localPort = 57216], acknowledgeMode = AUTO本地队列大小= 0 11:01:47.873 [SimpleAsyncTaskExecutor-1] DEBUG o.s.a.r.l.BlockingQueueConsumer - 检索消费者的递送: tags = [{amq.ctag-NzonI8Ja7yjfWuLGLsi4pA = job.queue}],channel = Cached Rabbit Channel:AMQChannel(amqp://BipUser@10.165.18.29:5672 /,1),conn: Proxy @ 64583ac5 Shared Rabbit Connection:SimpleConnection @ 61e800fb [delegate = amqp://BipUser@10.165.18.29:5672 /,localPort = 57216], acknowledgeMode = AUTO本地队列大小= 0 11:01:47.888 [SimpleAsyncTaskExecutor-1] DEBUG o.s.a.r.l.BlockingQueueConsumer - 检索消费者的递送: tags = [{amq.ctag-NzonI8Ja7yjfWuLGLsi4pA = job.queue}],channel = Cached Rabbit Channel:AMQChannel(amqp://BipUser@10.165.18.29:5672 /,1),conn: Proxy @ 64583ac5 Shared Rabbit Connection:SimpleConnection @ 61e800fb [delegate = amqp://BipUser@10.165.18.29:5672 /,localPort = 57216], acknowledgeMode = AUTO本地队列大小= 0 11:01:47.899 [SimpleAsyncTaskExecutor-1] DEBUG o.s.a.r.l.BlockingQueueConsumer - 检索消费者的递送: tags = [{amq.ctag-NzonI8Ja7yjfWuLGLsi4pA = job.queue}],channel = Cached Rabbit Channel:AMQChannel(amqp://BipUser@10.165.18.29:5672 /,1),conn: Proxy @ 64583ac5 Shared Rabbit Connection:SimpleConnection @ 61e800fb [delegate = amqp://BipUser@10.165.18.29:5672 /,localPort = 57216], acknowledgeMode = AUTO本地队列大小= 0 11:01:47.910 [SimpleAsyncTaskExecutor-1] DEBUG o.s.a.r.l.BlockingQueueConsumer - 检索消费者的递送: tags = [{amq.ctag-NzonI8Ja7yjfWuLGLsi4pA = job.queue}],channel = Cached Rabbit Channel:AMQChannel(amqp://BipUser@10.165.18.29:5672 /,1),conn: Proxy @ 64583ac5 Shared Rabbit Connection:SimpleConnection @ 61e800fb [delegate = amqp://BipUser@10.165.18.29:5672 /,localPort = 57216], acknowledgeMode = AUTO本地队列大小= 0 11:01:47.921 [SimpleAsyncTaskExecutor-1] DEBUG o.s.a.r.l.BlockingQueueConsumer - 检索消费者的递送: tags = [{amq.ctag-NzonI8Ja7yjfWuLGLsi4pA = job.queue}],channel = Cached Rabbit Channel:AMQChannel(amqp://BipUser@10.165.18.29:5672 /,1),conn: Proxy @ 64583ac5 Shared Rabbit Connection:SimpleConnection @ 61e800fb [delegate = amqp://BipUser@10.165.18.29:5672 /,localPort = 57216], acknowledgeMode = AUTO本地队列大小= 0 11:01:47.932 [SimpleAsyncTaskExecutor-1] DEBUG o.s.a.r.l.BlockingQueueConsumer - 检索消费者的递送: tags = [{amq.ctag-NzonI8Ja7yjfWuLGLsi4pA = job.queue}],channel = Cached Rabbit Channel:AMQChannel(amqp://BipUser@10.165.18.29:5672 /,1),conn: Proxy @ 64583ac5 Shared Rabbit Connection:SimpleConnection @ 61e800fb [delegate = amqp://BipUser@10.165.18.29:5672 /,localPort = 57216], acknowledgeMode = AUTO本地队列大小= 0 11:01:47.943 [SimpleAsyncTaskExecutor-1] DEBUG o.s.a.r.l.BlockingQueueConsumer - 检索消费者的递送: tags = [{amq.ctag-NzonI8Ja7yjfWuLGLsi4pA = job.queue}],channel = Cached Rabbit Channel:AMQChannel(amqp://BipUser@10.165.18.29:5672 /,1),conn: Proxy @ 64583ac5 Shared Rabbit Connection:SimpleConnection @ 61e800fb [delegate = amqp://BipUser@10.165.18.29:5672 /,localPort = 57216], acknowledgeMode = AUTO本地队列大小= 0 11:01:47.954 [SimpleAsyncTaskExecutor-1] DEBUG o.s.a.r.l.BlockingQueueConsumer - 检索消费者的递送: tags = [{amq.ctag-NzonI8Ja7yjfWuLGLsi4pA = job.queue}],channel = Cached Rabbit Channel:AMQChannel(amqp://BipUser@10.165.18.29:5672 /,1),conn: Proxy @ 64583ac5 Shared Rabbit Connection:SimpleConnection @ 61e800fb [delegate = amqp://BipUser@10.165.18.29:5672 /,localPort = 57216], acknowledgeMode = AUTO本地队列大小= 0 11:01:47.965 [SimpleAsyncTaskExecutor-1] DEBUG o.s.a.r.l.BlockingQueueConsumer - 检索消费者的递送: tags = [{amq.ctag-NzonI8Ja7yjfWuLGLsi4pA = job.queue}],channel = Cached Rabbit Channel:AMQChannel(amqp://BipUser@10.165.18.29:5672 /,1),conn: Proxy @ 64583ac5 Shared Rabbit Connection:SimpleConnection @ 61e800fb [delegate = amqp://BipUser@10.165.18.29:5672 /,localPort = 57216], acknowledgeMode = AUTO本地队列大小= 0 11:01:47.976 [SimpleAsyncTaskExecutor-1] DEBUG o.s.a.r.l.BlockingQueueConsumer - 检索消费者的递送: tags = [{amq.ctag-NzonI8Ja7yjfWuLGLsi4pA = job.queue}],channel = Cached Rabbit Channel:AMQChannel(amqp://BipUser@10.165.18.29:5672 /,1),conn: Proxy @ 64583ac5 Shared Rabbit Connection:SimpleConnection @ 61e800fb [delegate = amqp://BipUser@10.165.18.29:5672 /,localPort = 57216], acknowledgeMode = AUTO本地队列大小= 0 11:01:47.987 [SimpleAsyncTaskExecutor-1] DEBUG o.s.a.r.l.BlockingQueueConsumer - 检索消费者的递送: tags = [{amq.ctag-NzonI8Ja7yjfWuLGLsi4pA = job.queue}],channel = Cached Rabbit Channel:AMQChannel(amqp://BipUser@10.165.18.29:5672 /,1),conn: Proxy @ 64583ac5 Shared Rabbit Connection:SimpleConnection @ 61e800fb [delegate = amqp://BipUser@10.165.18.29:5672 /,localPort = 57216], acknowledgeMode = AUTO本地队列大小= 0
下面是我的log4j配置。 即使我只提到了文件appender,所有监听器日志都在我的应用服务器控制台中打印。
# LOG4J configuration
log4j.rootLogger=WARN
log4j.appender.Appender2=org.apache.log4j.FileAppender
log4j.appender.Appender2.File=C:\\Chandan\\bip.log
log4j.appender.Appender2.layout=org.apache.log4j.PatternLayout
log4j.appender.Appender2.layout.ConversionPattern=%-7p %d [%t] %c %x - %m%n
是否需要添加任何配置?
编辑帖子:
我在JAVA_OPTS中添加了-Dlog4j.debug=true
。 。请查看下面的日志。
log4j: Trying to find [log4j.xml] using context classloader WebappClassLoader
context: BIP
delegate: false
----------> Parent Classloader:
java.net.URLClassLoader@2626b418
.
log4j: Trying to find [log4j.xml] using WebappClassLoader
context: BIP
delegate: false
----------> Parent Classloader:
java.net.URLClassLoader@2626b418
class loader.
log4j: Trying to find [log4j.xml] using ClassLoader.getSystemResource().
log4j: Trying to find [log4j.properties] using context classloader WebappClassLoader
context: BIP
delegate: false
----------> Parent Classloader:
java.net.URLClassLoader@2626b418
.
log4j: Using URL [file:/C:/Chandan/SoftwareTools/apache-tomcat-8.0.33-windows-x64/apache-tomcat-8.0.33/webapps/BIP/WEB-INF/classes/log4j.properties] for automatic log4j configuration.
log4j: Reading configuration from URL file:/C:/Chandan/SoftwareTools/apache-tomcat-8.0.33-windows-x64/apache-tomcat-8.0.33/webapps/BIP/WEB-INF/classes/log4j.properties
log4j: Parsing for [root] with value=[file].
log4j: Level token is [file].
log4j: Category root set to DEBUG
log4j: Finished configuring.
我的项目结构如下所示。
以下是我的web.xml文件配置。
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>/WEB-INF/config/log4j.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
</listener>
答案 0 :(得分:0)
您可能正在从类路径中获取另一个配置文件,而不是使用您期望的配置文件。
使用-Dlog4j.debug=true
运行以查看正在使用的配置文件。
修改强>
添加
<priority value="warn" />
或
<priority value="info" />
到<root/>
记录器
答案 1 :(得分:0)
上面的答案可以解决您的问题,但如果您使用yaml文件将项目配置为application.yml,则可以在application.yml文件中设置此配置。
logging:
file: ./log/yourapplication.log
pattern:
console: "%d{HH:mm:ss.SSS} %-5level %logger{36} x-tid=%X{x-tid} - %msg%n"
level:
root: DEBUG
org.springframework.amqp.rabbit.listener: INFO
此配置解决了许多问题,我正在使用其他日志过滤器,如:
ch.qos.logback.core: INFO
org.hibernate: INFO
com.zaxxer.hikari.pool: DEBUG