Welcome! Log In Create A New Profile

Advanced

How can I remove backslash when log_format use escape=json

October 18, 2018 09:29AM
Hi, I want to log my entire request_body, but access.log contains some strange backslash, how can I remove these backslash before doube quote?

Here is my nginx.conf,
```
log_format main escape=json '$request_body';

access_log logs/access.log main;
```

This is my request code:
```
fetch('http://localhost:8080/njs',{
method:'POST',
body:JSON.stringify({
text:'message with backslash'
})
}).then(res=>res.json()).then((res)=>{
console.info(res)
})
```

And access.log
```
{\"text\":\"message with backslash\"}
```

But I think it should be
```
{"text":"message with backslash"}
```
Subject Author Posted

How can I remove backslash when log_format use escape=json

kimown October 18, 2018 09:29AM

Re: How can I remove backslash when log_format use escape=json

akashverma February 20, 2019 05:33AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 145
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready