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

HTTP Connection Pool: how to filter debug logging? #1013

Closed
bormotov opened this issue Apr 5, 2017 · 6 comments
Closed

HTTP Connection Pool: how to filter debug logging? #1013

bormotov opened this issue Apr 5, 2017 · 6 comments
Labels
1 - triaged Tickets that are safe to pick up for contributing in terms of likeliness of being accepted bug help wanted Identifies issues that the core team will likely not have time to work on t:client Issues related to the HTTP Client t:core Issues related to the akka-http-core module
Milestone

Comments

@bormotov
Copy link

bormotov commented Apr 5, 2017

akka-http 10.0.5
logging via SLF4J (logback).

we use <pattern>%d{ISO8601} [%-5p] %m%n</pattern> and got in log a lot of

2017-04-05 15:03:42,079 [DEBUG] [12] <unconnected> Slot was stopped
2017-04-05 15:03:42,079 [DEBUG] [13] <unconnected> Slot was stopped
2017-04-05 15:03:42,079 [DEBUG] [14] <unconnected> Slot was stopped
2017-04-05 15:03:42,079 [DEBUG] [15] <unconnected> Slot was stopped

How filter this from log?

First try - add %c, to get log event category (typicaly hold className), but

2017-04-05 15:09:29,683 [DEBUG] WE/Pool(shared->http://host.url:80) [7] <unconnected> Slot was stopped
2017-04-05 15:09:29,683 [DEBUG] WE/Pool(shared->http://host.url:80) [8] <unconnected> Slot was stopped
2017-04-05 15:09:29,683 [DEBUG] WE/Pool(shared->http://host.url:80) [9] <unconnected> Slot was stopped
2017-04-05 15:09:43,477 [DEBUG] akka.io.TcpOutgoingConnection Could not establish connection to ....

but why?

Any ideas?

@jrudolph jrudolph added 1 - triaged Tickets that are safe to pick up for contributing in terms of likeliness of being accepted bug t:client Issues related to the HTTP Client t:core Issues related to the akka-http-core module help wanted Identifies issues that the core team will likely not have time to work on labels Apr 12, 2017
@jrudolph
Copy link
Member

These are log messages for the connection pool. We have both a logSource and a logClass but, unfortunately, because of the way the logger is constructed the logSource is the string you see (which is fine) but the logClass is DummyClassForStringSources.

We should make sure the logClass is something specific to the connection pool so it can be easily matched using the common logging tools.

@ochrons
Copy link

ochrons commented Apr 26, 2017

This is extremely annoying, bloating logs with no easy way to filter them out. Please provide a workaround or a logback config how to filter these away ASAP.

@ktoso
Copy link
Member

ktoso commented Apr 26, 2017

If you want a thing to be done "ASAP" you can provide a pull request or get commercial support.
We all have some priorities, and going around requesting something ASAP will not help a thing be done sooner in face of actual other real high priority things.

Thanks in advance.

@jrudolph
Copy link
Member

I agree with @ochrons on this one. I messed up that logging. I thought that at least the DummyClassForStringSources would end up in slf4j so you could filter on that one but that is filtered out specifically in akka-slf4j.

The way it is now, you cannot use the Akka Http 10.0.5 client because you have to completely disable DEBUG logging for your application otherwise you will drown in those logs and cannot do much about it.

@jrudolph
Copy link
Member

A workaround is to define a custom LoggingFilter and configure it in akka.logging-filter that filters out those messages before they are even posted.

The default slf4j logging filter will use whatever settings you define in your logging backend's client configuration but you could provide a custom one as well that filters out those message directly.

See here for sl4j's default filter: https://github.com/akka/akka/blob/master/akka-slf4j/src/main/scala/akka/event/slf4j/Slf4jLogger.scala#L134

A custom implementation that filters out all debug messages from them pool (as witnessed by containing "/Pool(" in the logSource) could look like this:

package xyz
import akka.event.slf4j.Logger

class CustomAkkaHttpSlf4jLoggingFilter(settings: ActorSystem.Settings, eventStream: EventStream) extends LoggingFilter {
  def isErrorEnabled(logClass: Class[_], logSource: String) =
    (eventStream.logLevel >= ErrorLevel) && Logger(logClass, logSource).isErrorEnabled
  def isWarningEnabled(logClass: Class[_], logSource: String) =
    (eventStream.logLevel >= WarningLevel) && Logger(logClass, logSource).isWarnEnabled
  def isInfoEnabled(logClass: Class[_], logSource: String) =
    (eventStream.logLevel >= InfoLevel) && Logger(logClass, logSource).isInfoEnabled
  def isDebugEnabled(logClass: Class[_], logSource: String) =
    !logSource.contains("/Pool(") &&
    (eventStream.logLevel >= DebugLevel) && Logger(logClass, logSource).isDebugEnabled
}

You enable it by setting

akka.log-filter = xyz.CustomAkkaHttpSlf4jLoggingFilter

@ochrons
Copy link

ochrons commented Apr 26, 2017

Got it working fine with this filter, thanks for the quick response!

jrudolph added a commit to jrudolph/akka-http that referenced this issue Apr 26, 2017
Before, the log source was the descriptive string that describes
the pool but that can be hard to match on in logging backends. Now,
logging backends will see "PoolGateway" as the source for all pool
logging statements (still not quite the common practice but will
simplify to filter on all messages relating to the client pool).
jrudolph added a commit to jrudolph/akka-http that referenced this issue Apr 26, 2017
Before, the log source was the descriptive string that describes
the pool but that can be hard to match on in logging backends. Now,
logging backends will see "PoolGateway" as the source for all pool
logging statements (still not quite the common practice but will
simplify to filter on all messages relating to the client pool).
jrudolph added a commit to jrudolph/akka-http that referenced this issue Apr 26, 2017
Before, the log source was the descriptive string that describes
the pool but that can be hard to match on in logging backends. Now,
logging backends will see "PoolGateway" as the source for all pool
logging statements (still not quite the common practice but will
simplify to filter on all messages relating to the client pool).

Fixes akka#1013.
ktoso pushed a commit that referenced this issue Apr 27, 2017
Before, the log source was the descriptive string that describes
the pool but that can be hard to match on in logging backends. Now,
logging backends will see "PoolGateway" as the source for all pool
logging statements (still not quite the common practice but will
simplify to filter on all messages relating to the client pool).

Fixes #1013.
@ktoso ktoso added this to the 10.0.6 milestone Apr 27, 2017
tomrf1 pushed a commit to tomrf1/akka-http that referenced this issue Aug 13, 2017
Before, the log source was the descriptive string that describes
the pool but that can be hard to match on in logging backends. Now,
logging backends will see "PoolGateway" as the source for all pool
logging statements (still not quite the common practice but will
simplify to filter on all messages relating to the client pool).

Fixes akka#1013.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1 - triaged Tickets that are safe to pick up for contributing in terms of likeliness of being accepted bug help wanted Identifies issues that the core team will likely not have time to work on t:client Issues related to the HTTP Client t:core Issues related to the akka-http-core module
Projects
None yet
Development

No branches or pull requests

4 participants