Search code examples
playframeworkakkathreadpoolakka-httpapplication.conf

Logging akka configs on Application Start is not working in Play Framework 2.8


I am using latest play framework (2.8.12) I am trying to Print akka configs on application start Here is how my configs looks like

application.conf

play {
  server {
    # The server provider class name
    provider = "play.core.server.AkkaHttpServerProvider"

    akka {
        loglevel = "INFO"
        log-config-on-start = on
        
        default-dispatcher {
               fork-join-executor {
                 parallelism-min = 8
                 parallelism-factor = 32.0
                 parallelism-max = 64
                 task-peeking-mode = "FIFO"
              }
        }
    }
  }
}

Trying to tune thread pool settings but none of changes seems to be effected. So trying to log configs on application start.


Solution

  • First thing I would do is just print the provided config from one of your controllers for example.

    @Singleton
    class ConfigController @Inject()(val controllerComponents: ControllerComponents, val config: Config)
        extends BaseController {
    
      println(config.root().render())
    ...
    }
    
    

    Please note that will print full config including all reference.conf found in your classpath.


    Regarding your application.conf, I think you misplaced the default-dispatcher config. It must be in akka.actor instead of play.server.akka

    play.server.provider = "play.core.server.AkkaHttpServerProvider"
    
    akka {
      loglevel = "INFO"
      log-config-on-start = on
      actor.default-dispatcher {
        executor = fork-join-executor
        fork-join-executor {
          parallelism-min = 8
          parallelism-factor = 32.0
          parallelism-max = 64
          task-peeking-mode = "FIFO"
        }
      }
    }
    
    

    To make log-config-on-start work, make sure that you configure logback.xml logger akka to allow INFO logs.

    <logger name="akka" level="INFO"/>