Comments (8)
Just Add a <PatternLayout/>
element to your config...
<RabbitMQ name="rabbitmq"
addresses="localhost:5672"
host="localhost" port="5672" user="guest" password="guest" virtualHost="/"
exchange="log4j2Test" exchangeType="fanout" declareExchange="true" durable="true" autoDelete="false"
applicationId="testAppId" routingKeyPattern="%X{applicationId}.%c.%p"
contentType="text/plain" contentEncoding="UTF-8" generateId="true" deliveryMode="NON_PERSISTENT"
charset="UTF-8"
clientConnectionProperties="foo:bar,baz:qux"
async="false"
senderPoolSize="3" maxSenderRetries="5">
<PatternLayout pattern="%d %5p [%t] %m%n" />
</RabbitMQ>
from spring-amqp-samples.
Please don't use github issues to ask questions; use Stack Overflow instead [spring-amqp] tag.
Issues are for reporting bugs or asking for new features.
from spring-amqp-samples.
I think we can add that <PatternLayout>
into the sample to avoid similar questions in the future
from spring-amqp-samples.
Thank you so much for your patience and such a fast answer! Indeed it works, I just tried and I have log messages including the threadname. Now, a suggestion, that you may or may not consider worth of tracking via an Issue.
By using an AMQP reader program it can be found that a number of different log message fields are mapped to the AMQP message header structure as in this sample:
#contentHeader<basic>(
content-type=text/plain,
content-encoding=UTF-8,
headers={
level=TRACE,
location=es.companyname.logging.demo.WriteLogs.main()[23],
categoryName=es.tsystems.logging.demo.WriteLogs
},
delivery-mode=2,
priority=0,
correlation-id=null,
reply-to=null,
expiration=null,
message-id=null,
timestamp=Thu Aug 10 14:02:03 CEST 2017,
type=null,
user-id=null,
app-id=logging-amqp-log4j,
cluster-id=null
)
When indexing and storing the logs via Logstash and Elasticsearch, for example, there will be always the need of obtaining the threadname, so that each execution path can be isolated for browsing, f.e. with Kibana.
With the patternlayout, now I have log messages as follows:
"message":"2017-08-11 17:37:38,104 INFO [pool-1-1] END something to log in one thread\r\n"
If I want to obtain the threadname ( 'pool-1-1' in the example), I need to code in logstash a filter to get it out of the message text. Not difficult, but error prone and dependent on message layout. Would it make more sense to have it included in the 'headers' structure, together with 'level', 'location' and 'categoryName'?
The other thing that strikes me is to see that '\r\n' at the end of each text message, I am not including a carriage feed at the end of the log messages, so, why is it there?
Thanks again!
from spring-amqp-samples.
I opened AMQP-761.
from spring-amqp-samples.
%n
adds the newline; remove it from your pattern.
from spring-amqp-samples.
Yes, that was it... Thanks!
from spring-amqp-samples.
By the way; capturing the location
(calling class and line) header is quite expensive; you might want to consider adding includeLocation="false"
to your Logger
elements...
<Logger name="foo" level="info" includeLocation="false">
<AppenderRef ref="rabbitmq" />
</Logger>
from spring-amqp-samples.
Related Issues (20)
- Fix for Running Receiver and Sender at the same time on a Single Server HOT 3
- Add example for delayed message HOT 2
- Exception when I run the example of log4j2 with rabbitmq in docker HOT 8
- Wrong documentation for delayed message HOT 1
- Spring Rabbit Json pom.xml points to non existing repo? HOT 2
- log4j module have error when run HOT 6
- Request response pattern example HOT 1
- how to find params with amp HOT 2
- Invalid property 'rabbitTemplate' of bean class RabbitMarketDataGateway HOT 1
- build stock has error HOT 1
- RabbitMQ - Socket Exception HOT 1
- Cannot build the project due to missing artefacts in maven central repository HOT 4
- Change confirms/returns sample to use CorrelationData.getFuture()
- How to configure Global Error Handler @RabbitListener annotation's errorHandler attribute HOT 4
- Sample log4j2 doesn't work with spring-boot >=2.0.0.RELEASE HOT 1
- spring-rabbit-stocks webapp does not work
- how to create multiple rabbitmq HOT 1
- hi!help me HOT 14
- spring-amqp with mqtt HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from spring-amqp-samples.