Friday, June 15, 2018

Dropwizard logging appender error

Leave a Comment

I have a dropwizard service which has been running for months with logging to console. I wanted to now log to file so I added the following extra lines to my config file:

    logging:    # Permit DEBUG, INFO, WARN and ERROR messages to be logged by appenders.   level: INFO   appenders:     - type: file       currentLogFilename: ./log/taskiir-service.log       threshold: ALL       archive: true       archivedLogFilenamePattern: ./log/taskiir-service-%d.log       archivedFileCount: 5       timeZone: UTC 

However when I try to run the service now I get the following error:

    io.dropwizard.configuration.ConfigurationParsingException: taskiir-service.yml has an error:   * Failed to parse configuration at: logging.appenders.[0]; Could not resolve type id 'file' as a subtype of [simple type, class io.dropwizard.logging.AppenderFactory<ch.qos.logback.classic.spi.ILoggingEvent>]: known type ids = [] (for POJO property 'appenders')  at [Source: UNKNOWN; line: -1, column: -1] (through reference chain: com.anton.taskiirservice.TaskiirService.TaskiirAPIConfiguration["logging"]->io.dropwizard.logging.DefaultLoggingFactory["appenders"]->java.util.ArrayList[0])      at io.dropwizard.configuration.ConfigurationParsingException$Builder.build(ConfigurationParsingException.java:276)     at io.dropwizard.configuration.BaseConfigurationFactory.build(BaseConfigurationFactory.java:157)     at io.dropwizard.configuration.BaseConfigurationFactory.build(BaseConfigurationFactory.java:92)     at io.dropwizard.cli.ConfiguredCommand.parseConfiguration(ConfiguredCommand.java:124)     at io.dropwizard.cli.ConfiguredCommand.run(ConfiguredCommand.java:72)     at io.dropwizard.cli.Cli.run(Cli.java:75)     at io.dropwizard.Application.run(Application.java:93)     at com.anton.taskiirservice.TaskiirService.TaskiirAPIApplication.main(TaskiirAPIApplication.java:59) Caused by: com.fasterxml.jackson.databind.exc.InvalidTypeIdException: Could not resolve type id 'file' as a subtype of [simple type, class io.dropwizard.logging.AppenderFactory<ch.qos.logback.classic.spi.ILoggingEvent>]: known type ids = [] (for POJO property 'appenders')  at [Source: UNKNOWN; line: -1, column: -1] (through reference chain: com.anton.taskiirservice.TaskiirService.TaskiirAPIConfiguration["logging"]->io.dropwizard.logging.DefaultLoggingFactory["appenders"]->java.util.ArrayList[0])     at com.fasterxml.jackson.databind.exc.InvalidTypeIdException.from(InvalidTypeIdException.java:43)     at com.fasterxml.jackson.databind.DeserializationContext.invalidTypeIdException(DeserializationContext.java:1615)     at com.fasterxml.jackson.databind.DeserializationContext.handleUnknownTypeId(DeserializationContext.java:1186)     at com.fasterxml.jackson.databind.jsontype.impl.TypeDeserializerBase._handleUnknownTypeId(TypeDeserializerBase.java:291)     at com.fasterxml.jackson.databind.jsontype.impl.TypeDeserializerBase._findDeserializer(TypeDeserializerBase.java:162)     at com.fasterxml.jackson.databind.jsontype.impl.AsPropertyTypeDeserializer._deserializeTypedForId(AsPropertyTypeDeserializer.java:113)     at com.fasterxml.jackson.databind.jsontype.impl.AsPropertyTypeDeserializer.deserializeTypedFromObject(AsPropertyTypeDeserializer.java:97)     at com.fasterxml.jackson.databind.deser.AbstractDeserializer.deserializeWithType(AbstractDeserializer.java:254)     at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:287)     at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:244)     at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:27)     at com.fasterxml.jackson.databind.deser.SettableBeanProperty.deserialize(SettableBeanProperty.java:519)     at com.fasterxml.jackson.module.afterburner.deser.SettableObjectMethodProperty.deserializeAndSet(SettableObjectMethodProperty.java:47)     at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:287)     at com.fasterxml.jackson.databind.deser.BeanDeserializer._deserializeOther(BeanDeserializer.java:189)     at com.fasterxml.jackson.module.afterburner.deser.SuperSonicBeanDeserializer.deserialize(SuperSonicBeanDeserializer.java:120)     at com.fasterxml.jackson.databind.jsontype.impl.AsPropertyTypeDeserializer._deserializeTypedUsingDefaultImpl(AsPropertyTypeDeserializer.java:178)     at com.fasterxml.jackson.databind.jsontype.impl.AsPropertyTypeDeserializer.deserializeTypedFromObject(AsPropertyTypeDeserializer.java:105)     at com.fasterxml.jackson.databind.deser.AbstractDeserializer.deserializeWithType(AbstractDeserializer.java:254)     at com.fasterxml.jackson.databind.deser.impl.MethodProperty.deserializeAndSet(MethodProperty.java:129)     at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:251)     at com.fasterxml.jackson.module.afterburner.deser.SuperSonicBeanDeserializer.deserialize(SuperSonicBeanDeserializer.java:155)     at com.fasterxml.jackson.databind.ObjectMapper._readValue(ObjectMapper.java:3972)     at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2264)     at io.dropwizard.configuration.BaseConfigurationFactory.build(BaseConfigurationFactory.java:128)     ... 6 more 

Any ideas most welcome, thanks.

Here is the POM file (using Eclipse):

<?xml version="1.0" encoding="UTF-8"?> <project         xmlns="http://maven.apache.org/POM/4.0.0"         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">      <modelVersion>4.0.0</modelVersion>     <prerequisites>         <maven>3.0.0</maven>     </prerequisites>      <groupId>com.anton.taskiirservice</groupId>     <artifactId>TaskiirService</artifactId>     <version>0.0.1-SNAPSHOT</version>     <packaging>jar</packaging>      <name>TaskiirAPI</name>      <properties>         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>         <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>         <dropwizard.version>1.2.2</dropwizard.version>         <mainClass>com.anton.taskiirservice.TaskiirService.TaskiirAPIApplication</mainClass>         <swagger.version>1.5.3-M1</swagger.version>         <jdk.version>1.8</jdk.version>     </properties>       <dependencies>         <dependency>             <groupId>io.dropwizard</groupId>             <artifactId>dropwizard-core</artifactId>             <version>${dropwizard.version}</version>         </dependency>         <dependency>             <groupId>io.dropwizard</groupId>             <artifactId>dropwizard-jdbi</artifactId>             <version>${dropwizard.version}</version>         </dependency>          <dependency>             <groupId>mysql</groupId>             <artifactId>mysql-connector-java</artifactId>             <version>5.1.39</version>         </dependency>          <dependency>             <groupId>com.wordnik</groupId>             <artifactId>swagger-annotations</artifactId>             <version>${swagger.version}</version>         </dependency>      <dependency>         <groupId>org.elasticsearch.client</groupId>         <artifactId>transport</artifactId>         <version>5.3.2</version>     </dependency>     <dependency>       <groupId>com.google.code.gson</groupId>       <artifactId>gson</artifactId>       <version>2.7</version>       <scope>compile</scope>     </dependency>       </dependencies>      <build>         <plugins>             <plugin>                 <artifactId>maven-shade-plugin</artifactId>                 <version>2.4.1</version>                 <configuration>                     <createDependencyReducedPom>true</createDependencyReducedPom>                     <transformers>                         <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>                         <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">                             <mainClass>${mainClass}</mainClass>                         </transformer>                     </transformers>                     <!-- exclude signed Manifests -->                     <filters>                         <filter>                             <artifact>*:*</artifact>                             <excludes>                                 <exclude>META-INF/*.SF</exclude>                                 <exclude>META-INF/*.DSA</exclude>                                 <exclude>META-INF/*.RSA</exclude>                             </excludes>                         </filter>                     </filters>                 </configuration>                 <executions>                     <execution>                         <phase>package</phase>                         <goals>                             <goal>shade</goal>                         </goals>                         <configuration>                             <transformers>                                 <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>                                 <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">                                     <mainClass>${mainClass}</mainClass>                                 </transformer>                             </transformers>                         </configuration>                      </execution>                 </executions>             </plugin>             <plugin>                 <artifactId>maven-jar-plugin</artifactId>                 <version>2.6</version>                 <configuration>                     <archive>                         <manifest>                             <addClasspath>true</addClasspath>                             <mainClass>${mainClass}</mainClass>                         </manifest>                     </archive>                 </configuration>             </plugin>             <plugin>                 <artifactId>maven-compiler-plugin</artifactId>                 <version>3.6.1</version>                 <configuration>                     <source>1.8</source>                     <target>1.8</target>                 </configuration>             </plugin>             <plugin>                 <artifactId>maven-source-plugin</artifactId>                 <version>2.4</version>                 <executions>                     <execution>                         <id>attach-sources</id>                         <goals>                             <goal>jar</goal>                         </goals>                     </execution>                 </executions>             </plugin>             <plugin>                 <artifactId>maven-javadoc-plugin</artifactId>                 <version>2.10.3</version>                 <executions>                     <execution>                         <id>attach-javadocs</id>                         <goals>                             <goal>jar</goal>                         </goals>                     </execution>                 </executions>             </plugin>         </plugins>     </build>      <reporting>         <plugins>             <plugin>                 <artifactId>maven-project-info-reports-plugin</artifactId>                 <version>2.8.1</version>                 <configuration>                     <dependencyLocationsEnabled>false</dependencyLocationsEnabled>                     <dependencyDetailsEnabled>false</dependencyDetailsEnabled>                 </configuration>             </plugin>             <plugin>                 <artifactId>maven-javadoc-plugin</artifactId>                 <version>2.10.3</version>             </plugin>         </plugins>     </reporting> </project> 

0 Answers

If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment