Kotlin Serverless Framework Logging Fix


If you are interested in using the Serverless Framework with Kotlin on AWS you will likely find the aws-kotlin-jvm-gradle.

For example this command will create a service:

serverless create --template aws-kotlin-jvm-gradle --path your_service

This template seems to work fine but I came accross an issue when attempting to debug errors in Cloudwatch. The errors will mention things like ERROR StatusLogger Unrecognized format specifier which is preceded by ERROR StatusLogger No log4j2 configuration file found

This was quite confusing as the base template contains the log4j configuration file and if you decompile the assembled binary that file does get packaged up for the deployment.

After digging around it looks like there is an issue with shadowJar and how it packages the file. The configuration file is packaged but just not correctly

As best I can tell there may be a recent change that broke Log4j2PluginsCacheFileTransformer and I just happened to come accross it at an unfortunate time.


Add the Log4j2PluginsCacheFileTransformer to your build.gradle file.

  • Add the plugin to the top of the file:
import com.github.jengelman.gradle.plugins.shadow.transformers.Log4j2PluginsCacheFileTransformer
  • Add this before the build.finalizedBy(shadowJar) call:
shadowJar {

After making that change and redeploying the logs started flowing as they should.