Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option to change log format to JSON #59

Open
MichaelSasser opened this issue Oct 22, 2023 · 1 comment
Open

Option to change log format to JSON #59

MichaelSasser opened this issue Oct 22, 2023 · 1 comment

Comments

@MichaelSasser
Copy link

MichaelSasser commented Oct 22, 2023

First off, thank you for putting in the work. This is a super helpful project.


I would appreciate it if it was possible to enable an option besides LOG_WITHOUT_NEWLINE and DISABLE_REQUEST_LOGS to have one line per request in the log output formatted as JSON.

One of the reasons is that I don't use the logs on the host machine directly. They might get scraped and processed out of order by Loki, so they might not end up next to each other. The second reason is that it would be simpler to parse them when they had the same format.

@mendhak
Copy link
Owner

mendhak commented Dec 3, 2023

Hi I tried rereading a few times, but I didn't understand, there's already one line per request in JSON format?

I ran:

docker run -e DISABLE_REQUEST_LOGS=true -e LOG_WITHOUT_NEWLINE=true -p 8080:8080 -p 8443:8443 --rm -t mendhak/http-https-echo:30

And the log lines look like this:

{"path":"/v1/completions","headers":{"host":"localhost:8080","user-agent":"curl/7.81.0","accept":"*/*","content-type":"application/json"},"method":"GET","body":"","fresh":false,"hostname":"localhost","ip":"::ffff:172.17.0.1","ips":[],"protocol":"http","query":{},"subdomains":[],"xhr":false,"os":{"hostname":"0970983690cd"},"connection":{}}
{"path":"/aaaaaaa/bbbbbbbbb/ccccccccc","headers":{"host":"localhost:8080","user-agent":"curl/7.81.0","accept":"*/*","content-type":"application/json"},"method":"GET","body":"","fresh":false,"hostname":"localhost","ip":"::ffff:172.17.0.1","ips":[],"protocol":"http","query":{},"subdomains":[],"xhr":false,"os":{"hostname":"0970983690cd"},"connection":{}}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants