article

Amelia@Amazon avatar image
Amelia@Amazon posted

How to debug your (Java) Alexa skill?

Summary:

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 log4j.properties 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.logger.helloworld=debug
log4j.rootLogger=warn, tail

log4j.appender.tail=org.apache.log4j.ConsoleAppender
log4j.appender.tail.File=${catalina.base}/logs/catalina.log
log4j.appender.tail.layout=org.apache.log4j.PatternLayout
log4j.appender.tail.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n

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

Keywords: ASK, Debug, Java, SLF4J

KB_0018

alexa skills kit
10 |5000 characters needed characters left characters exceeded

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

Article

Contributors

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