2016-06-21 76 views
1

我只是試圖添加日誌配置dropwizard的yaml配置文件。我跑dropwizard版本0.9.2,和我的YAML包含此:爲什麼不能dropwizard配置我的記錄器?

logging: 
    level: INFO 
    appenders: 
    - type: file 
     currentLogFilename: ./log/mylogfile.log 
     threshold: ALL 
     archive: true 
     archivedLogFilenamePattern: ./log/mylogfile-%d{yyyy-MM-dd-HH}.log 
     archivedFileCount: 5 
     timeZone: UTC 
     logFormat: # TODO 

和我fatjar肯定有

META-INF /服務/ io.dropwizard.logging.AppenderFactory

這包含

io.dropwizard.logging.ConsoleAppenderFactory 
io.dropwizard.logging.FileAppenderFactory 
io.dropwizard.logging.SyslogAppenderFactory 

,但我得到這個在啓動...

9:29:28 AM web.1 | * Failed to parse configuration at: logging.appenders.[0]; Could not resolve type id 'file' into a subtype of [simple type, class io.dropwizard.logging.AppenderFactory]: known type ids = [AppenderFactory] 
9:29:28 AM web.1 | at [Source: N/A; line: -1, column: -1] (through reference chain: com.salesforce.analytics.query.AppConfiguration["logging"]->io.dropwizard.logging.DefaultLoggingFactory["appenders"]->java.util.ArrayList[0]) 

任何幫助至於我在做什麼錯?

+0

這隻發生?你的類路徑配置是否正確? – pandaadb

+0

這是一個fatjar,其他類路徑上需要的東西? –

回答

0

請檢查您的yml文件中是否使用了選項卡,而不是使用雙倍空間我使用的是以下日誌配置及其工作正常,同時驗證您需要包含maven shade插件的pom文件還添加了我的pom文件的構建部分

logging: 
    # The default level of all loggers. Can be OFF, ERROR, WARN, INFO, DEBUG, TRACE, or ALL. 
    level: INFO 
    loggers: 
    "org.skife.jdbi.v2": TRACE 
    appenders: 
    - type: file 
     # The file to which current statements will be logged. 
     currentLogFilename: ./logs/mylogfile.log 

     # When the log file rotates, the archived log will be renamed to this and gzipped. The 
     # %d is replaced with the previous day (yyyy-MM-dd). Custom rolling windows can be created 
     # by passing a SimpleDateFormat-compatible format as an argument: "%d{yyyy-MM-dd-hh}". 
     archivedLogFilenamePattern: ./logs/mylogfile-%d.log.gz 

     # The number of archived files to keep. 
     archivedFileCount: 5 

     # The timezone used to format dates. HINT: USE THE DEFAULT, UTC. 
     timeZone: UTC 

POM文件的插件

通過你的脂肪-JAR運行時
<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> 
        </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.3</version> 
       <configuration> 
        <source>1.7</source> 
        <target>1.7</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> 
相關問題