2016-06-21 6 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

yahそれはfatjar、クラスパスに必要なものは何ですか? –

答えて

0

ymlファイルのタブを使用しているかどうかを確認してください。二重スペースを使用しています。以下のログ設定を使用しています。また、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 

ポンポンファイルのプラグインあなたの脂肪の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>