Comments (8)
You need to disable pretty-print, that is, prettyPrintEnabled=false
. Would you mind confirming if that fixes your issue, please?
from log4j2-logstash-layout.
Thanks for your reply, this problem has been solved, but this seems to be more complicated than the JsonLayout that comes with log4j2. Do you have any suggestions for this?
from log4j2-logstash-layout.
@a1046149428, I am having a hard time to follow you. Would you mind first describing what are you trying to achieve, please? What is your setup? Are you trying to pipe LogstashLayout
-generated JSONs to Logstash with a SocketAppender
? I would appreciate if you can provide a minimal setup that I can reproduce your problem and work on a solution.
from log4j2-logstash-layout.
Thank you for your attention, the configuration I used is temporarily unavailable because it is at home. But the format I want is as shown below. I hope that this layout can provide information about the actual content of the application, rather than the json with many layers as shown above.
from log4j2-logstash-layout.
@a1046149428 I can't help unless I know the setup. Please do provide a simple setup that I can reproduce the problem myself. Sharing a Kibana screenshot does not help really.
from log4j2-logstash-layout.
Thank you for your patience, this is my steps:
the setup
from log4j2-logstash-layout.
Ok, this is strange. I am not able reproduce the error. I started Logstash 7.2.0 with the following configuration as described in the documentation:
input {
tcp {
port => 3456
codec => json
}
}
filter {
date {
match => [ "timeMillis", "UNIX_MS" ]
}
}
output {
stdout {}
}
Opened log42j-logstash-layout
project in my IDE and changed layout-demo/src/main/resources/log4j2.xml
as follows:
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="warn">
<Appenders>
<Socket name="LOGSTASH" host="localhost" port="3456" protocol="TCP">
<LogstashLayout dateTimeFormatPattern="yyyy-MM-dd'T'HH:mm:ss.SSSZZZ"
eventTemplateUri="classpath:LogstashJsonEventLayoutV1.json"
prettyPrintEnabled="false"
stackTraceEnabled="true"/>
</Socket>
</Appenders>
<Loggers>
<Root level="info">
<AppenderRef ref="LOGSTASH"/>
</Root>
</Loggers>
</Configuration>
Added a Thread.sleep(1_000L);
line to the bottom of LogstashLayoutDemo.java
(to give the SocketAppender
sufficient time to flush) and started main()
. Following is what I appeared in my console running Logstash:
{
"thread_name" => "main",
"logger_name" => "com.vlkan.log4j2.logstash.layout.demo.LogstashLayoutDemo",
"host" => "172.17.0.1",
"@version" => 1,
"message" => "Hello, world!",
"@timestamp" => 2019-07-06T20:33:24.910Z,
"port" => 46894,
"source_host" => "tahta",
"level" => "INFO"
}
{
"thread_name" => "main",
"logger_name" => "com.vlkan.log4j2.logstash.layout.demo.LogstashLayoutDemo",
"host" => "172.17.0.1",
"@version" => 1,
"message" => "Hello, error!",
"@timestamp" => 2019-07-06T20:33:24.931Z,
"port" => 46894,
"exception" => {
"stacktrace" => "java.lang.RuntimeException: test\n\tat com.vlkan.log4j2.logstash.layout.demo.LogstashLayoutDemo.main(LogstashLayoutDemo.java:11)\n",
"exception_class" => "java.lang.RuntimeException",
"exception_message" => "test"
},
"source_host" => "tahta",
"level" => "ERROR"
}
Did you configure your Logstash properly? Would you mind comparing your setup with mine, please?
from log4j2-logstash-layout.
Sorry, I can't reproduce this problem either.
The computer that had problems at the time was my company.
I remember that I was reviving this problem at home, but I couldn't find similar data in elastic search, maybe it was covered or deleted by me.
But I am sure there is no problem with my logstash configuration.
Maybe it is caused by other environmental variables.
By the way, what I am at home is filebeat, maybe this is not the same?
Filebeat.inputs:
- type: tcp
Max_message_size: 10MiB
Host: "0.0.0.0:9000"
Output.elasticsearch:
# Array of hosts to connect to.
Hosts: ["172.17.0.6:9200"]
Anyway I will close this issue, which does not involve the log42 layout.
Last but not least, I am glad that my problem has been solved, thank you very much for your help.
from log4j2-logstash-layout.
Related Issues (20)
- BufferOverflowException get thrown for messages of a larger size HOT 7
- LogstashLayout with log4j2-elasticsearch appender HOT 1
- Introduce properties to globally set LogstashLayout.Builder defaults
- Nullpointer exceptions at LogstashLayoutSerializationContexts$StringTruncatingGeneratorDelegate HOT 1
- Any template ready for GCP? HOT 9
- Message lost if exceeding maxStringLength and emptyPropertyExclusionEnabled is true HOT 4
- Use ByteArrayOutputStream instead of ByteBufferOutputStream to avoid message loss HOT 8
- Stacktraces larger than maxStringLength are not truncated HOT 7
- Failed serializing JSON: BufferOverflowException HOT 10
- How to output ThreadContext (ex -MDC fields) HOT 1
- Review request for Log4j JsonTemplateLayout HOT 7
- How exactly is MapMessage supposed to be handled? HOT 7
- Multiple template variables in single property lead to an exception HOT 2
- Fallback for json:map: fields for libraries HOT 1
- NoClassDefFoundError: logstash.layout.resolver.TemplateResolvers (initialization failure) HOT 1
- Remove max byte count cap? HOT 1
- Reference whole MapMessage - and not just keys HOT 13
- Compiling with JDK 8 results in java.lang.NoSuchMethodError: java.nio.ByteBuffer.flip()Ljava/nio/ByteBuffer; HOT 4
- Marker lookup subsitutes literal string when marker not available HOT 1
- BufferOverflowException occurs intermittently when sending data via socket appender HOT 2
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 log4j2-logstash-layout.