Custom Logging for Play Scala Application

Logging functionality is a must for any application. It provides a clear view on what application is doing, greatly simplifies the debugging process, and records any mishaps when the application is running in the production environment.


By default, Play Framework includes logging functionality for the application and the framework. We will add a minor customization to reduce the Play and third-party logs to a minimum, while having a clear print out of the application logic.

Using IntelliJ, expand conf directory and open logback.xml file.

To simplify the log file access, change the file appender directory to logs/application.log.

Add a new logger entry above the play and application loggers. Name the new logger and set the level to DEBUG. Change play logger level to WARN and application logger level to INFO.

For your reference, several logging levels are available:

  • OFF - Used to turn off logging, not as a message classification.
  • ERROR - Runtime errors, or unexpected conditions.
  • WARN - Use of deprecated APIs, poor use of API, ‘almost’ errors, other runtime situations that are undesirable or unexpected, but not necessarily “wrong”.
  • INFO - Interesting runtime events such as application startup and shutdown.
  • DEBUG - Detailed information on the flow through the system.
  • TRACE - Most detailed information.

As you develop the application, experiment with different levels for the play, application, and custom loggers to see how much information you would like to see.  At LineDrop, we mostly keep the codebase logging set to DEBUG, occasionally changing it to TRACE to observe low level operations.

Uncomment ASYNCFILE entry in the root node to enable writing of the logs to a file.

Example: LineDrop Play/Scala Web Application - Configuration

Log Utility

To easily access the customer logger, add the Log object to your project.

Usage Example

Related Articles

Browse related articles

Get our stories delivered

From us to your inbox weekly.

Thank you!

Look for our next article in your mailbox.