Slf4jLoggingFilter/logback level filtering issue

353 views
Skip to first unread message

vacuumstate

unread,
Jan 12, 2017, 5:26:23 AM1/12/17
to Akka User List
Hi,

I'm having trouble trying to get logging working as per standard akka documentation.

The application consists of several scala/sbt assembly jars deployed to a 'bin' folder along with their *.conf HOCON and logback.xml files (which are excluded from the assembly packaging).


The issue is with trying to get the level filtering working i.e. it doesn't have any effect; - with all levels set to "warning' in logback.xml, I'm still getting debug and info logging output.


The logback.xml must be used to some extent, because the log output is matching the logback.xml pattern.

A log.conf is included by the other conf files:

akka {
  log-dead-letters = 0
  log-dead-letters-during-shutdown = off
  warn-about-java-serializer-usage = off
  loglevel = DEBUG
  stdout-loglevel = WARNING
  loggers = ["akka.event.slf4j.Slf4jLogger"]
  logging-filter = "akka.event.slf4j.Slf4jLoggingFilter"
}

And here is the logback.xml

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
        <target>System.out</target>
        <encoder>
            <pattern>%X{akkaTimestamp}| %-6level| %logger{36}| %X{sourceActorSystem}| %msg%n</pattern>
        </encoder>
    </appender>

    <logger name="akka" level="error" />
    <logger name="akka.cluster.Cluster" level="error" />
    <logger name="jobs" level="warning" />
    
    <root level="warning">
        <appender-ref ref="CONSOLE"/>
    </root>
</configuration>

And here are the library dependencies from one of the build.sbt files (scala version is 2.12.1):

libraryDependencies ++= {
  val akkaVersion = "2.4.16"
  Seq(
    "org.scala-lang"          % "scala-reflect"                       % "2.12.1",
    "org.scala-lang.modules"  % "scala-xml_2.12"                      % "1.0.6",
    "com.typesafe.akka"       %% "akka-actor"                         % akkaVersion,
    "com.typesafe.akka"       %% "akka-slf4j"                         % akkaVersion,
    "com.typesafe.akka"       %% "akka-remote"                        % akkaVersion,
    "com.typesafe.akka"       %% "akka-cluster"                       % akkaVersion,
    "com.typesafe.akka"       %% "akka-cluster-tools"                 % akkaVersion,
    "ch.qos.logback"          %  "logback-classic"                    % "1.1.8",
    "org.eclipse.persistence" % "eclipselink"                         % "2.6.4",
    "javax.el"                % "javax.el-api"                        % "3.0.0",
    "com.typesafe.akka"       %% "akka-multi-node-testkit"            % akkaVersion   % "test",
    "com.typesafe.akka"       %% "akka-testkit"                       % akkaVersion   % "test",
    "org.scalatest"           %% "scalatest"                          % "3.0.1"       % "test",
    "com.novocode"            % "junit-interface"                     % "0.11"        % "test"
  )
}

I'd appreciate any clues on how to resolve this!

Thanks,

Rob.

Viktor Klang

unread,
Jan 12, 2017, 5:30:24 AM1/12/17
to Akka User List
run the app with -Dakka.log-config-on-start=on

--
>>>>>>>>>> Read the docs: http://akka.io/docs/
>>>>>>>>>> Check the FAQ: http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
---
You received this message because you are subscribed to the Google Groups "Akka User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to akka-user+unsubscribe@googlegroups.com.
To post to this group, send email to akka...@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.



--
Cheers,

vacuumstate

unread,
Jan 12, 2017, 7:20:55 AM1/12/17
to Akka User List
So I investigated running the app with  -Dakka.log-config-on-start=on.

I couldn't get any associated config output until I reverted log.conf to use the default logger:

akka {
log-config-on-start=on

log-dead-letters = 0
log-dead-letters-during-shutdown = off
warn-about-java-serializer-usage = off
  loglevel = INFO
stdout-loglevel = INFO
loggers = ["akka.event.Logging$DefaultLogger"]
//loggers = ["akka.event.slf4j.Slf4jLogger"]
//logging-filter = "akka.event.slf4j.Slf4jLoggingFilter"
}

...and then I get loads of config output to the log, especially from reference.conf dragged in from some other dependency.

Clearly, my understanding of how {assembly fat jars, configuration loading, external config files, slf4j, logback} hang together is not complete!

I'll continue investigation as to why I get no output (at all) with:

akka {
log-dead-letters = 0
log-dead-letters-during-shutdown = off
warn-about-java-serializer-usage = off
  loglevel = INFO
stdout-loglevel = INFO

loggers = ["akka.event.slf4j.Slf4jLogger"]
logging-filter = "akka.event.slf4j.Slf4jLoggingFilter"
}

and

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<target>System.out</target>
<encoder>
            <pattern>!check! %X{akkaTimestamp}| %-6level| %logger{36}| %X{sourceActorSystem}| %msg%n</pattern>
        </encoder>
</appender>

<logger name="akka" level="error" />
<logger name="akka.cluster.Cluster" level="error" />
    <logger name="jobs" level="info" />
<logger name="jobsHttp" level="info" />

<root level="info">

vacuumstate

unread,
Jan 12, 2017, 4:17:53 PM1/12/17
to Akka User List
I'll admit that it is in fact working as expected - apologies.

To recap the pieces relating to the fact I'm using assembly jars with external configuration files:
- exclude the config files from the assembly jars using sbt-assembly MergeStrategy.discard
- in code use ConfigFactory.load() together withFallback where necessary in conjunction with:
- specify -Dconfig.file=<each specific external conf file> when executing java with the assembly jar
- specify -Dlogback.configurationFile=./logback.xml
- follow the steps from the documentation

Reply all
Reply to author
Forward
0 new messages