Reputation: 1471
I have an use case where i need to load the Jmeter logs to elastic search without log-stash configurations.
The performance test case is being invoked using pom.xml jmeter-maven-plugin goal.
I wanted below message to be shipped into Elastic,
[INFO] summary = 180 in 00:00:01 = 182.6/s Avg: 0 Min: 0 Max: 0 Err: 180 (100.00%)
I tried the below mentioned in documentation, instead of log4j2xml i used logback.xml.
(link)
Advanced Log Configuration If you add a "log4j2.xml" into the (defaults to ${project.base.directory}/src/test/conf) it will now be copied into the /bin folder. If one does not exist the default one supplied with JMeter will be used instead.
i also tried to provide the config file as
mvn -X -DAPPCONFIG=home/App1 -Dlogback.configurationFile=file:path/to/conf/logback.xml -Duser.timezone=GMT com.lazerycode.jmeter:jmeter-maven-plugin:jmeter -Dtest=TestClass#testmethod
In both the cases the logback.xml is not being used. But i noticed that in git the pom.xml includes logback dependencies.
Any input, how to configure the logback.xml instead of log4j2.xml in the jmeter-maven-plugin?
Upvotes: 0
Views: 775
Reputation: 168147
Looking into Send the Logs of a Java App to the Elastic Stack it appears that you need to:
Add logstash-logback-encoder
to JMeter Classpath by adding the next line to pom.xml file:
<testPlanLibraries>
<artifact>net.logstash.logback:logstash-logback-encoder:6.2</artifact>
</testPlanLibraries>
Place a copy of log4j2.xml file to src/test/conf
folder of your Maven project and configure JMeter logging according to your requirements. Make sure to add Logstash appender to it like:
<appender name="STASH" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>/desired/location/of/the/log/file</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>/desired/location/of/the/log/file.%d{yyyy-MM-dd}.log</fileNamePattern>
<maxHistory>7</maxHistory>
</rollingPolicy>
<encoder class="net.logstash.logback.encoder.LogstashEncoder"/>
</appender>
<root level="DEBUG">
<appender-ref ref="STASH"/>
</root>
That should be it, you can not point the logback.xml
to read the configured file(s), convert the output to JSON and feed ELK stack with the data
Upvotes: 2