etaty / rediscala

Non-blocking, Reactive Redis driver for Scala (with Sentinel support)
Apache License 2.0
790 stars 142 forks source link

Logging & loglevel for RedisWorkerIO #66

Closed alexanderscott closed 9 years ago

alexanderscott commented 9 years ago

First of all, thank you for your efforts and contributions towards this package - it is very intuitive and useful.

However, the logging inside of RedisWorkerIO is a problem. Currently it binds to the implicit ActorSystem's LoggingAdapter (context.system.log) and I haven't found a reasonable way to silence connection/disconnection logging. It does not use getLogger like elsewhere in the code to provide for slf4j or log4j contextual logging. The loglevel in the reference.conf is not applied to Redis actors at all.

Disconnections are set to WARNING level, and reconnections are are INFO level. This is very annoying and chatty to run against a production Redis instance which frequently disconnects long-lived redis clients (reconnection handled by the driver).

Could you please update the logging to mute the particularly egregious WARN levels or apply a specific LoggingAdapter (log4j or slf4j style)? I have forks for both - can open a pull.

Thank you!

etaty commented 9 years ago

Hi,

The loglevel in the reference.conf is not applied to Redis actors at all. It is a commented line

I suppose you are speaking about : https://github.com/alexanderscott/rediscala/commit/6901e54a3e653fbde42a1bf1b253bcfca33b54bd Can you do a pull request ?

In the end you would like to overwrite the output level of rediscala with a conf file in log4j or slf4j ?

alexanderscott commented 9 years ago

I see it is commented - didn't realize it was used in the tests to set redis-server verbosity. And yes, the goal was to quiet the logging coming from RedisClient b/c it is filling up logs at WARN-level with a non-issue.

Figured out how to quiet the reconnection logging coming from the RedisClientActor by setting loglevel for the package inside of a local logback file. So this isn't really an issue anymore.

Opened pull regardless with logging via slf4j and log4j. Not a critical contribution - really up to you whether or not to merge.

Thanks again.

AlexLaviolette commented 5 years ago

@alexanderscott I'm having trouble quieting the connection logging. Would you mind sharing what you added to the logback conf to fix it?

alexanderscott commented 5 years ago

@AlexLaviolette can quiet logging by adding this line into your logback.xml configuration file, which should live in your static resources dir:

 <logger name="redis" level="ERROR"/>

And add logback as a library dependency to the project:

libraryDependencies += "ch.qos.logback"  % "logback-classic" % "1.0.9"

Can set your akka.loglevel to whatever in config, but it should still obey the rules established by logback.

Example logback.xml:

<?xml version="1.0" encoding="UTF-8"?>

<configuration>

    <logger name="redis" level="ERROR"/>

    <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
        <encoder>
            <pattern>%date %X{akkaSource} %highlight(%-5level) %cyan(%logger{5}) - %msg %n</pattern>
        </encoder>
    </appender>

    <root level="DEBUG">
        <appender-ref ref="CONSOLE"/>
    </root>

</configuration>
AlexLaviolette commented 5 years ago

@alexanderscott I had tried something like that but it didn't seem to work. I'll give it another shot, thanks a bunch!