Amelia@Amazon avatar image
Amelia@Amazon posted

How to debug your (Java) Alexa skill?


When developing an Alexa skill it is recommended that developers output logs from their code to assist with the debugging process. Developers have the option of choosing the logging framework they would like to use. The sample code included with the Alexa Skills Kit uses the SLF4J logging framework.

Developers can use the companion app to view errors. In addition, SLF4J provides 5 different logging levels which are ERROR, WARN, INFO, DEBUG, TRACE in the order. The use of log levels should be differentiated by the developers.

Developers can control the level of log output by setting it in the file in Java Resources > src directory. For example you may want to output up to DEBUG level in beta environment and only produce ERROR or WARN logs in the production environment to reduce the size of log files. Additionally different log levels can be set for each Java class.

log4j.rootLogger=warn, tail

log4j.appender.tail.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n

The above example file shows a way to output the logs as part of Tomcat log for AWS Elastic Beanstalk environment.

Keywords: ASK, Debug, Java, SLF4J


alexa skills kit
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.



wangchao contributed to this article nick_gardner contributed to this article brizzlebrazzle contributed to this article