{"action":"opened","issue":{"url":"https://api.github.com/repos/akka/akka/issues/17801","labels_url":"https://api.github.com/repos/akka/akka/issues/17801/labels{/name}","comments_url":"https://api.github.com/repos/akka/akka/issues/17801/comments","events_url":"https://api.github.com/repos/akka/akka/issues/17801/events","html_url":"https://github.com/akka/akka/issues/17801","id":90086127,"number":17801,"title":"Slf4jLogger incompatible with logback's TurboFilter mechanism","user":{"login":"fommil","id":1914041,"avatar_url":"https://avatars.githubusercontent.com/u/1914041?v=3","gravatar_id":"","url":"https://api.github.com/users/fommil","html_url":"https://github.com/fommil","followers_url":"https://api.github.com/users/fommil/followers","following_url":"https://api.github.com/users/fommil/following{/other_user}","gists_url":"https://api.github.com/users/fommil/gists{/gist_id}","starred_url":"https://api.github.com/users/fommil/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fommil/subscriptions","organizations_url":"https://api.github.com/users/fommil/orgs","repos_url":"https://api.github.com/users/fommil/repos","events_url":"https://api.github.com/users/fommil/events{/privacy}","received_events_url":"https://api.github.com/users/fommil/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-06-22T12:32:21Z","updated_at":"2015-06-22T12:32:21Z","closed_at":null,"body":"As discussed in https://groups.google.com/d/msg/akka-user/YVri58taWsM/X6-XR0_i1nwJ\r\n\r\nThe Slf4jLogger is logging `{}` for all messages, passing the actual message as a parameter and therefore any Logback `TurboFilter`s will not behave correctly.\r\n\r\nI propose the following change, which has the fortunate side-effect of earlier filtering based on the SLF4J logging levels.\r\n\r\n```scala\r\ndef receive = {\r\n    case event @ Error(cause, logSource, logClass, message) =>\r\n      withMdc(logSource, event) {\r\n        val logger = Logger(logClass, logSource)\r\n        if (logger.isErrorEnabled()) {\r\n          cause match {\r\n            case Error.NoCause | null => logger.error(if (message != null) message.toString else null)\r\n            case _ => logger.error(if (message != null) message.toString else cause.getLocalizedMessage, cause)\r\n          }\r\n        }\r\n      }\r\n\r\n    case event @ Warning(logSource, logClass, message) =>\r\n      withMdc(logSource, event) {\r\n        val logger = Logger(logClass, logSource)\r\n        if (logger.isWarnEnabled()) {\r\n          logger.warn(message.toString)\r\n        }\r\n      }\r\n\r\n    case event @ Info(logSource, logClass, message) =>\r\n      withMdc(logSource, event) {\r\n        val logger = Logger(logClass, logSource)\r\n        if (logger.isInfoEnabled()) {\r\n          logger.info(message.toString)\r\n        }\r\n      }\r\n\r\n    case event @ Debug(logSource, logClass, message) =>\r\n      withMdc(logSource, event) {\r\n        val logger = Logger(logClass, logSource)\r\n        if (logger.isDebugEnabled()) {\r\n          logger.debug(message.toString)\r\n        }\r\n      }\r\n\r\n    case InitializeLogger(_) =>\r\n      sender() ! LoggerInitialized\r\n  }\r\n```\r\n"}}