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

OPENAI_LOG has no effect when okhttp level is also specified #73

Open
stargazer33 opened this issue Jan 1, 2025 · 3 comments
Open

OPENAI_LOG has no effect when okhttp level is also specified #73

stargazer33 opened this issue Jan 1, 2025 · 3 comments

Comments

@stargazer33
Copy link

stargazer33 commented Jan 1, 2025

--

@stargazer33
Copy link
Author

I was wrong: just discovered this:

okhttp3.level=WARNING
okhttp3.internal.level=WARNING

in my logging configuration

@TomerAberbach
Copy link
Collaborator

TomerAberbach commented Jan 1, 2025

Interesting, thanks for the report!

Does that configuration you pasted override our configuration? If so, then maybe I could look into logging a warning when they're both specified. Or at least including a note in the readme or something

@TomerAberbach TomerAberbach reopened this Jan 1, 2025
@TomerAberbach TomerAberbach changed the title logging does not work: OPENAI_LOG has no effect OPENAI_LOG has no effect when okhttp level is also specified Jan 1, 2025
@stargazer33
Copy link
Author

stargazer33 commented Jan 2, 2025

Does that configuration you pasted override our configuration? If so, then maybe I could look into logging a warning...

OK, what I see on console is this:

...
<6> okhttp3.OkHttpClient           --> POST http://localhost:11434/v1/chat/completions http/1.1
<6> okhttp3.OkHttpClient           Authorization: ██
<6> okhttp3.OkHttpClient           User-Agent: OpenAIClientImpl/Java 1.8.0_431
...

It means: ACTUALLY it is okhttp3.OkHttpClient class that using java.util.logging API to write logs.
And java.util.logging is quite a flexible thing: it CAN be customized/configured, and I customized and configured it as I need.
The missing date/time and this <6> in the log output - this is result of my customization

And, I configured in my logging.properties (config file for java.util.logging) this:

okhttp3.level=WARNING

You can configure logging levels per package/class.
I did this because some other component of my program used OkHttpClient and was logging TOO much, so I limited it (only warnings)

It turns out: openai client write logs using the SAME class name.
Well, it use the same library (okhttp3).
Is it clear?

Well, I would suggest the following:

  1. Short term: do nothing :-)
    Well, you can add to your README something like
    "when enabling logging - check configuration of your logging framework, ensure okhttp3.OkHttpClient is NOT disabled in your settings"

  2. Long term, low priority ( pls fix missing Javadoc/sources first!!! ) feature: investigate how to write logs under "openai" package name instead of "okhttp3".

When you writing logs using "openai" package name: you do not need that proprietary OPENAI_LOG env. variable:
users of your library will configure logging of "com.openai..." using existing configuration of their logging framework - like with any other good Java library )))

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