b-s-d
b-s-d

Reputation: 5143

How do I enable DynamoDB Local Logging?

More than often DynamoDB Local does not show descriptive error messages, in order to see internal errors you need to enable logging.

What are the steps to enable DynamoDB Local logging on the standard output?

Upvotes: 17

Views: 9823

Answers (2)

chaixxiv
chaixxiv

Reputation: 441

  1. Go to the directory that has the DynamoDBLocal.jar
  2. Create a file called log4j2.xml with these contents:
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN">
  <Appenders>
      <Console name="Console" target="SYSTEM_OUT">
              <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
      </Console>
  </Appenders>
  <Loggers>
    <Logger name="com.amazonaws.services.dynamodbv2.local" level="DEBUG">
        <AppenderRef ref="Console"/>
    </Logger>
    <Logger name="com.amazonaws.services.dynamodbv2.local.shared.access.sqlite.SQLiteDBAccess" level="INFO">
      <AppenderRef ref="Console"/>
    </Logger>
    <Root level="WARN">
      <AppenderRef ref="Console"/>
    </Root>
  </Loggers>
</Configuration>
  1. Remove the existing log4j2.xml from the jar

zip -d DynamoDBLocal.jar log4j2.xml

  1. Add the created log4j2.xml to the jar

zip -u DynamoDBLocal.jar log4j2.xml

or simply edit the log4j2.xml in the DynamoDBLocal.jar using 7-Zip etc. and overwrite it with the xml above and skip the steps 2-4.

Upvotes: 17

b-s-d
b-s-d

Reputation: 5143

  1. Change to the directory with DynamoDBLocal.jar
  2. Create a new file called log4j.properties with the contents:

    log4j.rootLogger=DEBUG, stdout

    log4j.appender.stdout=org.apache.log4j.ConsoleAppender log4j.appender.stdout.layout=org.apache.log4j.PatternLayout log4j.appender.stdout.layout.ConversionPattern=LOG%d %p [%c] - %m%n

  3. Remove the existing log4j.properties files from the jar (there might be two)

    zip -d DynamoDBLocal.jar log4j.properties

    zip -d DynamoDBLocal.jar log4j.properties

  4. Add the new properties file to the jar

    zip -u DynamoDBLocal.jar log4j.properties

Source: https://gist.github.com/mdaley/aaf9b62d90f6817eb72a

Upvotes: 1

Related Questions