How can I remove backslash when log format use escape=json

kimown nginx-forum at forum.nginx.org
Thu Oct 18 13:29:31 UTC 2018


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"}
```

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,281634,281634#msg-281634



More information about the nginx mailing list