RabbitMQ Spring integration logging

1,071 views
Skip to first unread message

Eric NICOLAS

unread,
Dec 12, 2017, 5:17:26 AM12/12/17
to rabbitmq-users
Hi All,

I am using spring integration to move messages from a server to an other.
I would like to trace in a log file errors ( transfer , connection pb...) to supervise this file


File log4j.properties

    # Root logger option
    log4j.rootLogger=warn, stdout

    # Redirect log messages to console
    log4j.appender.stdout=org.apache.log4j.ConsoleAppender
    log4j.appender.stdout.Target=System.out
    log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
    log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss}, %d [%-5p] (%F:%M:%L) .%m. .%M. %n


My spring integration file :

    <int:logging-channel-adapter id="logChannel" level="warn" logger-name="stdout" log-full-message="true"  />

    <!-- Channel definition -->
    <int:channel id="myChannel" >
        <int:interceptors>
            <int:wire-tap channel="logChannel"/>
        </int:interceptors>
    </int:channel>
   
    <!-- ************* -->
    <!-- Source Broker -->
    <!-- ************* -->
    <rabbit:connection-factory id="connectionFactory" username="guest" password="guest" addresses="XX.XX.XX.XX:5672"  cache-mode="CONNECTION" connection-cache-size="50" virtual-host="/"/>
    <int-amqp:inbound-channel-adapter channel="myChannel" queue-names="myqueue" connection-factory="connectionFactory"  auto-startup="true" id="inboundChannelAdapter" channel-transacted="true" concurrent-consumers="5" prefetch-count="40"/>
   
     <!-- ****************** -->
     <!-- Destination Broker -->
     <!-- ****************** -->
    <rabbit:connection-factory id="connectionFactoryRmqDest" username="guest_fails" password="guest" addresses="YY.YY.YY.YY:5672" cache-mode="CONNECTION" connection-cache-size="50" virtual-host="/"/>
    <rabbit:template id="rabbitTemplateRmqDest" connection-factory="connectionFactoryRmqDest"/>
    <int-amqp:outbound-channel-adapter routing-key="keyMyQueue" channel="myChannel" exchange-name="direct.exchange" amqp-template="rabbitTemplateRmqDest" default-delivery-mode="PERSISTENT"/>

  
  
With the warn level i have in the console the stack trace. => OK
The stack trace is written:
    ... 24 more
Caused by: com.rabbitmq.client.AuthenticationFailureException: ACCESS_REFUSED - Login was refused using authentication mechanism PLAIN. For details see the broker logfile.
    at com.rabbitmq.client.impl.AMQConnection.start(AMQConnection.java:342)
    at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:909)
    at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:859)
    at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:799)
    at org.springframework.amqp.rabbit.connection.AbstractConnectionFactory.createBareConnection(AbstractConnectionFactory.java:352)
    ... 32 more
   
Is it possible to write only the error message "ACCESS_REFUSED - Login was refused using authentication mechanism PLAIN. For details see the broker logfile"?


But i also have message when it transfer messages normally? I would like to have no messages (for alerting only on errors)?
Messages are :
2017-12-12 11:11:20, 2017-12-12 11:11:20,503 [ERROR] (LoggingHandler.java:handleMessageInternal:192) .[B@166ed919. .handleMessageInternal.


What is the difference between the log level in the logging-channel and the rootLogger of the log4j.properties.
  
Thanks for help,

Regards,

Eric

Arnaud Cogoluègnes

unread,
Dec 12, 2017, 8:55:39 AM12/12/17
to rabbitm...@googlegroups.com
   
Is it possible to write only the error message "ACCESS_REFUSED - Login was refused using authentication mechanism PLAIN. For details see the broker logfile"?


I'm not sure this is easily doable, log messages are not usually customizable, and the createBareConnection method is final.
 

But i also have message when it transfer messages normally? I would like to have no messages (for alerting only on errors)?
Messages are :
2017-12-12 11:11:20, 2017-12-12 11:11:20,503 [ERROR] (LoggingHandler.java:handleMessageInternal:192) .[B@166ed919. .handleMessageInternal.


You may want to add a filter in the wire-tap channel to filter non-error messages.
 

What is the difference between the log level in the logging-channel and the rootLogger of the log4j.properties.

The log level in the logging-channel tag is the level at which log messages will be logged for Spring Integration messages going through this message handler. The level for the root logger is the severity limit, log messages under this limit won't show up in the appenders (file, console, etc). If you set e.g. level="DEBUG" and "log4j.rootLogger=info, stdout", log messages logged by the logging channel adapter won't show up as debug < info.

Eric NICOLAS

unread,
Jan 2, 2018, 10:15:25 AM1/2/18
to rabbitmq-users
Hi,

I added a wire-tap channel, this work fine with one channel.

Adding a second channel, i have problems to separate logs specific to one channel.

All logs are redirected to a global file , but i would like to have log file for each channels.
Following my log4j.properties:

# Root logger option
log4j.rootLogger=warn, logFileError

log4j.appender.logFileError=org.apache.log4j.RollingFileAppender
log4j.appender.logFileError.File=c:/tmp/logs/logFileError.log
log4j.appender.logFileError.MaxFileSize=2MB
log4j.appender.logFileError.MaxBackupIndex=10
log4j.appender.logFileError.layout=org.apache.log4j.PatternLayout
log4j.appender.logFileError.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %M%n


# Redirect log messages from the first channel to a log file
log4j.category.catLogChannel1=warn, logFileChannel1
log4j.appender.logFileChannel1=org.apache.log4j.RollingFileAppender
log4j.appender.logFileChannel1.File=c:/tmp/logs/logChannel1.log
log4j.appender.logFileChannel1.MaxFileSize=2MB
log4j.appender.logFileChannel1.MaxBackupIndex=10
log4j.appender.logFileChannel1.layout=org.apache.log4j.PatternLayout
log4j.appender.logFileChannel1.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %M%n


# Redirect log messages from the second channel to a log file
log4j.category.catLogChannel2=warn, logFileChannel2
log4j.appender.logFileChannel2=org.apache.log4j.RollingFileAppender
log4j.appender.logFileChannel2.File=c:/tmp/logs/logChannel2.log
log4j.appender.logFileChannel2.MaxFileSize=2MB
log4j.appender.logFileChannel2.MaxBackupIndex=10
log4j.appender.logFileChannel2.layout=org.apache.log4j.PatternLayout
log4j.appender.logFileChannel2.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %M%n


Files are created , but only the logFileError.log  is filled. Files dedicated for channels are empty.

Following the channel adapter configuration :

<int:logging-channel-adapter id="logChanne1" level="error" log-full-message="false"  logger-name="catLogChannel1" />
<int:logging-channel-adapter id="logChanne2" level="error" log-full-message="false"  logger-name="catLogChannel2" />



Thanks for your help,

Regards

Eric

Gary Russell

unread,
Jan 2, 2018, 1:53:49 PM1/2/18
to rabbitm...@googlegroups.com
Please ask questions about Spring Integration on Stack Overflow [1], tagged with [spring-integration].


--
You received this message because you are subscribed to the Google Groups "rabbitmq-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-users+unsubscribe@googlegroups.com.
To post to this group, send email to rabbitmq-users@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages