You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jmeter.apache.org by OUFDOU Anas <ou...@gmail.com> on 2023/03/31 06:48:21 UTC

[JMETER] Log on multiple line in CSV

Hello,

When failure message is multiline the CSV jtl file has a line logged on
multiline, there is no way to replace "\n" by "\\n" in the jtl file to have
one request by line ?
[image: image.png]


-- 
Cordialement,
-------------
Anas OUFDOU

Re: [JMETER] Log on multiple line in CSV

Posted by OUFDOU Anas <ou...@gmail.com>.
Thanks Felix.

On Sat, Apr 1, 2023 at 9:07 AM Felix Schumacher <
felix.schumacher@internetallee.de> wrote:

> Hi Anas,
>
> I can think of three more ways to achieve your goal. (Two of them are
> sketched out in the attached test plan).
>
> * Use a listener (as already proposed by Dmitri), but use it to change the
> assertion messages.
>    This can be done with a JSR 223 Listener with the following (Groovy)
> code:
>
> sampleResult.assertionResults.each {
> 	it.failureMessage = it.failureMessage
> 		.replaceAll("\n", "\\\\n")}
>
> * Use a *custom failure message* in the assertion.
>   For this, type in your message in the field "Custom failure message" at
> the bottom of the assertion.
>
> * Use a JSR 223 Assertion and do the check with a custom (Groovy) snippet.
>   With this, you can massage the message as it gets created.
>
> The listener described in the first point can be placed on the global
> level to change all "wrong" failure messages.
>
> It might be a good idea to extend the current JTL writer to make these
> changes itself. Maybe you want to raise a bug report?
>
> Hope this helps
>  Felix
>
> Am 01.04.23 um 07:55 schrieb OUFDOU Anas:
>
> Thanks stuart,
>
> The origine of \n is default jmeter message assertion not from response,
> There is no way to format data before logging to CSV ?
>
> Best regards
>
> On Fri, Mar 31, 2023 at 7:22 AM Stuart Kenworthy <St...@bjss.com> <St...@bjss.com>
> wrote:
>
>
> You could run a groovy jsr223 post processor on the sampler with the
> following lines
>
> String responseMessage = prev.getResponseMessage()
> prev.setResponseMessage(responseMessage.replace("\n", "\\n"))
>
> -----Original Message-----
> From: Dmitri T <gl...@live.com> <gl...@live.com>
> Sent: Friday, March 31, 2023 7:59 AM
> To: JMeter Users List <us...@jmeter.apache.org> <us...@jmeter.apache.org>; OUFDOU Anas <ou...@gmail.com>
> Subject: Re: [JMETER] Log on multiple line in CSV
>
> OUFDOU Anas wrote:
>
> Hello,
>
> When failure message is multiline the CSV jtl file has a line logged
> on multiline, there is no way to replace "\n" by "\\n" in the jtl file
> to have one request by line ?
> image.png
>
>
> --
> Cordialement,
> -------------
> Anas OUFDOU
>
> As of current JMeter stable version 5.5 <
> https://www.blazemeter.com/blog/jmeter-5-5> <https://www.blazemeter.com/blog/jmeter-5-5> it's not configurable and the
> only way to amend this is changing JMeter source code <https://github.com/apache/jmeter/blob/rel/v5.5/src/components/src/main/java/org/apache/jmeter/assertions/ResponseAssertion.java#L573
>
> ,
>
> re-compiling the .jar and replacing the original version of the
> ApacheJMeter_components <https://mvnrepository.com/artifact/org.apache.jmeter/ApacheJMeter_components
>
> with the amended one.
>
> Alternatively you can set jmeter.save.saveservice.assertion_results
> <https://jmeter.apache.org/usermanual/properties_reference.html#results_file_config
>
> property to *none* and store assertion results in a separate file using a
> Listener <https://jmeter.apache.org/usermanual/properties_reference.html#results_file_config
>
> .
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
> For additional commands, e-mail: user-help@jmeter.apache.org
>
>
> The information included in this email and any files transmitted with it
> may contain information that is confidential and it must not be used by, or
> its contents or attachments copied or disclosed to, persons other than the
> intended addressee. If you have received this email in error, please notify
> BJSS. In the absence of written agreement to the contrary BJSS' relevant
> standard terms of contract for any work to be undertaken will apply. Please
> carry out virus or such other checks as you consider appropriate in respect
> of this email. BJSS does not accept responsibility for any adverse effect
> upon your system or data in relation to this email or any files transmitted
> with it. BJSS Limited, a company registered in England and Wales (Company
> Number 2777575), VAT Registration Number 613295452, Registered Office
> Address, 1 Whitehall Quay, Leeds, LS1 4HR
>
>
>

-- 
Cordialement,
-------------
Anas OUFDOU

Re: [JMETER] Log on multiple line in CSV

Posted by Felix Schumacher <fe...@internetallee.de>.
Hi Anas,

I can think of three more ways to achieve your goal. (Two of them are 
sketched out in the attached test plan).

* Use a listener (as already proposed by Dmitri), but use it to change 
the assertion messages.
    This can be done with a JSR 223 Listener with the following (Groovy) 
code:

sampleResult.assertionResults.each{
	it.failureMessage=it.failureMessage.replaceAll("\n","\\\\n")
}

* Use a *custom failure message* in the assertion.
   For this, type in your message in the field "Custom failure message" 
at the bottom of the assertion.

* Use a JSR 223 Assertion and do the check with a custom (Groovy) snippet.
   With this, you can massage the message as it gets created.

The listener described in the first point can be placed on the global 
level to change all "wrong" failure messages.

It might be a good idea to extend the current JTL writer to make these 
changes itself. Maybe you want to raise a bug report?

Hope this helps
  Felix

Am 01.04.23 um 07:55 schrieb OUFDOU Anas:
> Thanks stuart,
>
> The origine of \n is default jmeter message assertion not from response,
> There is no way to format data before logging to CSV ?
>
> Best regards
>
> On Fri, Mar 31, 2023 at 7:22 AM Stuart Kenworthy<St...@bjss.com>
> wrote:
>
>> You could run a groovy jsr223 post processor on the sampler with the
>> following lines
>>
>> String responseMessage = prev.getResponseMessage()
>> prev.setResponseMessage(responseMessage.replace("\n", "\\n"))
>>
>> -----Original Message-----
>> From: Dmitri T<gl...@live.com>
>> Sent: Friday, March 31, 2023 7:59 AM
>> To: JMeter Users List<us...@jmeter.apache.org>; OUFDOU Anas <
>> oufdou.anas@gmail.com>
>> Subject: Re: [JMETER] Log on multiple line in CSV
>>
>> OUFDOU Anas wrote:
>>> Hello,
>>>
>>> When failure message is multiline the CSV jtl file has a line logged
>>> on multiline, there is no way to replace "\n" by "\\n" in the jtl file
>>> to have one request by line ?
>>> image.png
>>>
>>>
>>> --
>>> Cordialement,
>>> -------------
>>> Anas OUFDOU
>> As of current JMeter stable version 5.5< https://www.blazemeter.com/blog/jmeter-5-5>  it's not configurable and the
>> only way to amend this is changing JMeter source code <
>> https://github.com/apache/jmeter/blob/rel/v5.5/src/components/src/main/java/org/apache/jmeter/assertions/ResponseAssertion.java#L573
>>> ,
>> re-compiling the .jar and replacing the original version of the
>> ApacheJMeter_components <
>> https://mvnrepository.com/artifact/org.apache.jmeter/ApacheJMeter_components
>> with the amended one.
>>
>> Alternatively you can set jmeter.save.saveservice.assertion_results
>> <
>> https://jmeter.apache.org/usermanual/properties_reference.html#results_file_config
>> property to *none* and store assertion results in a separate file using a
>> Listener <
>> https://jmeter.apache.org/usermanual/properties_reference.html#results_file_config
>>> .
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail:user-unsubscribe@jmeter.apache.org
>> For additional commands, e-mail:user-help@jmeter.apache.org
>>
>>
>> The information included in this email and any files transmitted with it
>> may contain information that is confidential and it must not be used by, or
>> its contents or attachments copied or disclosed to, persons other than the
>> intended addressee. If you have received this email in error, please notify
>> BJSS. In the absence of written agreement to the contrary BJSS' relevant
>> standard terms of contract for any work to be undertaken will apply. Please
>> carry out virus or such other checks as you consider appropriate in respect
>> of this email. BJSS does not accept responsibility for any adverse effect
>> upon your system or data in relation to this email or any files transmitted
>> with it. BJSS Limited, a company registered in England and Wales (Company
>> Number 2777575), VAT Registration Number 613295452, Registered Office
>> Address, 1 Whitehall Quay, Leeds, LS1 4HR
>>
>

Re: [JMETER] Log on multiple line in CSV

Posted by OUFDOU Anas <ou...@gmail.com>.
Thanks stuart,

The origine of \n is default jmeter message assertion not from response,
There is no way to format data before logging to CSV ?

Best regards

On Fri, Mar 31, 2023 at 7:22 AM Stuart Kenworthy <St...@bjss.com>
wrote:

> You could run a groovy jsr223 post processor on the sampler with the
> following lines
>
> String responseMessage = prev.getResponseMessage()
> prev.setResponseMessage(responseMessage.replace("\n", "\\n"))
>
> -----Original Message-----
> From: Dmitri T <gl...@live.com>
> Sent: Friday, March 31, 2023 7:59 AM
> To: JMeter Users List <us...@jmeter.apache.org>; OUFDOU Anas <
> oufdou.anas@gmail.com>
> Subject: Re: [JMETER] Log on multiple line in CSV
>
> OUFDOU Anas wrote:
> > Hello,
> >
> > When failure message is multiline the CSV jtl file has a line logged
> > on multiline, there is no way to replace "\n" by "\\n" in the jtl file
> > to have one request by line ?
> > image.png
> >
> >
> > --
> > Cordialement,
> > -------------
> > Anas OUFDOU
> As of current JMeter stable version 5.5 <
> https://www.blazemeter.com/blog/jmeter-5-5> it's not configurable and the
> only way to amend this is changing JMeter source code <
> https://github.com/apache/jmeter/blob/rel/v5.5/src/components/src/main/java/org/apache/jmeter/assertions/ResponseAssertion.java#L573
> >,
> re-compiling the .jar and replacing the original version of the
> ApacheJMeter_components <
> https://mvnrepository.com/artifact/org.apache.jmeter/ApacheJMeter_components
> >
> with the amended one.
>
> Alternatively you can set jmeter.save.saveservice.assertion_results
> <
> https://jmeter.apache.org/usermanual/properties_reference.html#results_file_config
> >
> property to *none* and store assertion results in a separate file using a
> Listener <
> https://jmeter.apache.org/usermanual/properties_reference.html#results_file_config
> >.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
> For additional commands, e-mail: user-help@jmeter.apache.org
>
>
> The information included in this email and any files transmitted with it
> may contain information that is confidential and it must not be used by, or
> its contents or attachments copied or disclosed to, persons other than the
> intended addressee. If you have received this email in error, please notify
> BJSS. In the absence of written agreement to the contrary BJSS' relevant
> standard terms of contract for any work to be undertaken will apply. Please
> carry out virus or such other checks as you consider appropriate in respect
> of this email. BJSS does not accept responsibility for any adverse effect
> upon your system or data in relation to this email or any files transmitted
> with it. BJSS Limited, a company registered in England and Wales (Company
> Number 2777575), VAT Registration Number 613295452, Registered Office
> Address, 1 Whitehall Quay, Leeds, LS1 4HR
>


-- 
Cordialement,
-------------
Anas OUFDOU

RE: [JMETER] Log on multiple line in CSV

Posted by Stuart Kenworthy <St...@bjss.com.INVALID>.
You could run a groovy jsr223 post processor on the sampler with the following lines

String responseMessage = prev.getResponseMessage()
prev.setResponseMessage(responseMessage.replace("\n", "\\n"))

-----Original Message-----
From: Dmitri T <gl...@live.com>
Sent: Friday, March 31, 2023 7:59 AM
To: JMeter Users List <us...@jmeter.apache.org>; OUFDOU Anas <ou...@gmail.com>
Subject: Re: [JMETER] Log on multiple line in CSV

OUFDOU Anas wrote:
> Hello,
>
> When failure message is multiline the CSV jtl file has a line logged
> on multiline, there is no way to replace "\n" by "\\n" in the jtl file
> to have one request by line ?
> image.png
>
>
> --
> Cordialement,
> -------------
> Anas OUFDOU
As of current JMeter stable version 5.5 <https://www.blazemeter.com/blog/jmeter-5-5> it's not configurable and the only way to amend this is changing JMeter source code <https://github.com/apache/jmeter/blob/rel/v5.5/src/components/src/main/java/org/apache/jmeter/assertions/ResponseAssertion.java#L573>,
re-compiling the .jar and replacing the original version of the ApacheJMeter_components <https://mvnrepository.com/artifact/org.apache.jmeter/ApacheJMeter_components>
with the amended one.

Alternatively you can set jmeter.save.saveservice.assertion_results
<https://jmeter.apache.org/usermanual/properties_reference.html#results_file_config>
property to *none* and store assertion results in a separate file using a Listener <https://jmeter.apache.org/usermanual/properties_reference.html#results_file_config>.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
For additional commands, e-mail: user-help@jmeter.apache.org


The information included in this email and any files transmitted with it may contain information that is confidential and it must not be used by, or its contents or attachments copied or disclosed to, persons other than the intended addressee. If you have received this email in error, please notify BJSS. In the absence of written agreement to the contrary BJSS' relevant standard terms of contract for any work to be undertaken will apply. Please carry out virus or such other checks as you consider appropriate in respect of this email. BJSS does not accept responsibility for any adverse effect upon your system or data in relation to this email or any files transmitted with it. BJSS Limited, a company registered in England and Wales (Company Number 2777575), VAT Registration Number 613295452, Registered Office Address, 1 Whitehall Quay, Leeds, LS1 4HR

Re: [JMETER] Log on multiple line in CSV

Posted by Dmitri T <gl...@live.com>.
OUFDOU Anas wrote:
> Hello,
>
> When failure message is multiline the CSV jtl file has a line logged 
> on multiline, there is no way to replace "\n" by "\\n" in the jtl file 
> to have one request by line ?
> image.png
>
>
> -- 
> Cordialement,
> -------------
> Anas OUFDOU
As of current JMeter stable version 5.5 
<https://www.blazemeter.com/blog/jmeter-5-5> it's not configurable and 
the only way to amend this is changing JMeter source code 
<https://github.com/apache/jmeter/blob/rel/v5.5/src/components/src/main/java/org/apache/jmeter/assertions/ResponseAssertion.java#L573>, 
re-compiling the .jar and replacing the original version of the 
ApacheJMeter_components 
<https://mvnrepository.com/artifact/org.apache.jmeter/ApacheJMeter_components> 
with the amended one.

Alternatively you can set jmeter.save.saveservice.assertion_results 
<https://jmeter.apache.org/usermanual/properties_reference.html#results_file_config> 
property to *none* and store assertion results in a separate file using 
a Listener 
<https://jmeter.apache.org/usermanual/properties_reference.html#results_file_config>. 


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
For additional commands, e-mail: user-help@jmeter.apache.org