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

Too Many Logs #3033

Closed
cvkumar opened this issue May 24, 2017 · 8 comments
Closed

Too Many Logs #3033

cvkumar opened this issue May 24, 2017 · 8 comments

Comments

@cvkumar
Copy link

cvkumar commented May 24, 2017

Please answer these questions before submitting your issue.

What version of gRPC are you using?

1.0.0

What JVM are you using (java -version)?

1.8

What did you do?

If possible, provide a recipe for reproducing the error.
Not sure.

What did you expect to see?

No logs.

What did you see instead.

[id: 0xbf3948c7, L:/127.0.0.1:56373 - R:localhost/127.0.0.1:8080] DATA: streamId=5, padding=0, endStream=false, length=166, bytes=00000000a10a02696412640000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

------------------------------------
11:36:20.377 [grpc-default-worker-ELG-2-13] DEBUG io.grpc.netty.NettyClientHandler - 
----------------INBOUND--------------------

[id: 0xbf3948c7, L:/127.0.0.1:56373 - R:localhost/127.0.0.1:8080] DATA: streamId=5, padding=0, endStream=false, length=166, bytes=00000000a10a02696412640000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
11:36:20.377 [grpc-default-worker-ELG-2-13] DEBUG io.grpc.netty.NettyClientHandler - 
------------------------------------

I am pretty new to using grpc-java so this might be a very basic issue. When I run my code I receive extensive logging (seen above). So much so that it has crashed my IDE before. I have tried to follow the thread here:

#1577

Logger log = Logger.getlogger("io.grpc");
log.setLevel(Level.WARNING);

Unfortunately, I have had no success. Has anyone else seen this issue or know of a solution?

@ejona86
Copy link
Member

ejona86 commented May 24, 2017

Those are DEBUG-level logging, which is the most verbose logging. I can't really know where you have configuration that is enabling that level of logging, but the default is INFO.

@cvkumar
Copy link
Author

cvkumar commented May 24, 2017

Strange..... I don't think I'm setting the logging level anywhere in my app.

I've tried adding this to turn them off.

Logger log = Logger.getlogger("io.grpc");
log.setLevel(Level.WARNING);

Is there something else I can do?

@ericgribkoff
Copy link
Contributor

@cvkumar You can explicitly configure the logging settings by specifying a logging.properties file with contents like the following example:

handlers=java.util.logging.ConsoleHandler
io.grpc.level=INFO
java.util.logging.ConsoleHandler.level=INFO

And telling the JVM to use this file via the flag -Djava.util.logging.config.file=logging.properties. For the HelloWorld example generated by gradle, the command line would look like env JAVA_OPTS=-Djava.util.logging.config.file=logging.properties build/install/examples/bin/hello-world-client

@ejona86 FWIW, using a fresh download of jdk1.8.0_101 to run the gRPC examples results in similar logging output for me locally as well.

@ericgribkoff
Copy link
Contributor

@ejona86 I was incorrect - apparently at some point I had modified the default jdk1.8.0_101/jre/lib/logging.properties file to change the default logging level. @cvkumar It is worth checking your JRE-level config file to see if your settings different from the default.

@thomasjungblut
Copy link

any clues about this? I have a really hard time to disable the logging and it is super verbose.

Maybe the frame logging should be enabled via a config switch instead?
https://github.com/grpc/grpc-java/blob/master/netty/src/main/java/io/grpc/netty/NettyClientHandler.java#L134

I don't seem to have any other debug logs besides that pesky frame logger.

@cvkumar
Copy link
Author

cvkumar commented Jun 15, 2017

Feel pretty silly about it, but I haven't found a solution for this either.

@thomasjungblut
Copy link

I worked around it by forcing log4j as the logging backend and setting io.netty to INFO.

static {
        InternalLoggerFactory.setDefaultFactory(Log4JLoggerFactory.INSTANCE);
        LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
        Configuration config = ctx.getConfiguration();
        LoggerConfig loggerConfig = config.getLoggerConfig("io.netty");
        loggerConfig.setLevel(Level.INFO);
        ctx.updateLoggers();
    }

@adam-26
Copy link

adam-26 commented Jun 19, 2017

This happens because netty uses SLF4J and it will bind to a logging framework if it exists in your class path.

Removing the log output is a 2 step process.

  1. Determine the logging framework SLF4J is bound to
  2. Configure the bound logging framework so that it doesn't write debug output

An example of doing this can be found on StackOverflow (the code below is copied from the StackOverflow post).

import org.slf4j.impl.StaticLoggerBinder;

// 1. Determine what logging framework SLF4J is bound to:
final StaticLoggerBinder binder = StaticLoggerBinder.getSingleton();

// this will print the name of the logger factory to stdout
System.out.println(binder.getLoggerFactoryClassStr());

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

No branches or pull requests

6 participants