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

Logging to other client's file #985

Closed
Donutellko opened this issue Jun 8, 2019 · 2 comments
Closed

Logging to other client's file #985

Donutellko opened this issue Jun 8, 2019 · 2 comments
Labels
bug Unexpected or incorrect behavior help wanted Issues we need help with tackling

Comments

@Donutellko
Copy link

Donutellko commented Jun 8, 2019

Hello.
I have two Feign clients in a Spring Boot project, they are both configured like this (Kotlin):

@Configuration
class FirstConfig {
    @Bean
    fun getFirstClient(): FirstClient {
        return Feign.builder()
                .logger(Logger.JavaLogger().appendToFile("logs/first.log"))
                .logLevel(Logger.Level.FULL)
                .decoder(JacksonDecoder())
                .encoder(JacksonEncoder())
                .target(FirstClient::class.java, "...")
    }
}

And similarly for SecondClient and second.log (all the names are changed).

The issue is that I get two log files mixed. Something like that:
logs/second.log:

[FirstClient#someMethod] ---> GET http://.../... HTTP/1.1
...
[FirstClient#someMethod] <--- END HTTP (3629-byte body)
[SecondClient#otherMethod] ---> POST https://.../... HTTP/1.1
...
[SecondClient#send] ---> END HTTP (767-byte body)
[FirstClient#oneMoreMethod] ---> GET http://.../... HTTP/1.1
...

And the second.log is full of FirstClient's logs and vice versa. diff says the files are almost identical, but not completely -- two or three logs from first client does not appear in second's file.

I use version 10.1.0:

dependencies {
    compile 'io.github.openfeign:feign-core:10.1.0'
    compile 'io.github.openfeign:feign-jackson:10.1.0'
    ...

Thank you.

@Donutellko
Copy link
Author

I found that the problem is caused by 165th line in feign\Logger.java:
logger = java.util.logging.Logger.getLogger(Logger.class.getName());
So this method returns the same object for both instances of feign\JavaLogger.java. Would the change of an identifier be an appropriate solution?

@kdavisk6 kdavisk6 added bug Unexpected or incorrect behavior help wanted Issues we need help with tackling labels Jun 18, 2019
@dharmeshjogadia
Copy link
Contributor

Hey @Donutellko
I have one suggestion here to solve this problem, rather than using the default constructor of feign\JavaLogger.java we can introduce constructor with a parameter name or class. Something like
public JavaLogger(Class<?> clazz) and public JavaLogger(String name). what do you thing @kdavisk6 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Unexpected or incorrect behavior help wanted Issues we need help with tackling
Projects
None yet
Development

No branches or pull requests

3 participants