[logback-dev] [JIRA] Commented: (LBCLASSIC-292) Support optional include files

Ceki Gulcu (JIRA) noreply-jira at qos.ch
Thu Sep 8 20:38:16 CEST 2011

    [ http://jira.qos.ch/browse/LBCLASSIC-292?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12116#action_12116 ] 

Ceki Gulcu commented on LBCLASSIC-292:

Have you tried using conditionals?

Here is an example (requires Janino library)
   <!-- the FileExistsPropertyDefiner is not *currently* part of logback -->
   <define name="INCLUDED_FILE_EXISTS" class=" ch.qos.logback.core.property.FileExistsPropertyDefiner">
   <if condition="property("INCLUDED_FILE_EXISTS").equals("true")">
        <include file="/path/to/included/file">

Here is a tentative implementation for FileExistsPropertyDefiner:

package ch.qos.logback.core.property

import ch.qos.logback.core.PropertyDefinerBase;
import java.io.File;

public class FileExistsPropertyDefiner extends PropertyDefinerBase {
  String path;
  public String getPath() {   return path;   }

  public void setPath(String path) {   this.path = path;   }

  public String getPropertyValue() {
    if(path == null)
      return "false";
    File file = new File(path);
      return "true";
    return "false";

> Support optional include files
> ------------------------------
>                 Key: LBCLASSIC-292
>                 URL: http://jira.qos.ch/browse/LBCLASSIC-292
>             Project: logback-classic
>          Issue Type: Improvement
>          Components: joran
>    Affects Versions: 0.9.26
>            Reporter: Joachim Durchholz
>            Assignee: Logback dev list
>            Priority: Minor
> Logback emits a warning if a file named in <include/> isn't present.
> Sometimes, an included configuration file is purely optional. E.g. I would want to mail a more verbose configuration to a customer who has some mysterious error where the standard logging simply isn't detailed enough.
> Unfortunately, this means that in the standard case, I'll be spammed with the missing file warning, plus heaps of INFO messages. This might distract from relevant logback configuration problems.
> Suggestion: extend <include/> so that it accepts <include optional="true" ... />. If an include is optional, it will not generate error messages if the requested configuration is not present.
> The loading code might want to differentiate between "does not exist" (to suppress the message) and other problems (which probably should still be reported).

This message is automatically generated by JIRA.
If you think it was sent incorrectly contact one of the administrators: http://jira.qos.ch/secure/Administrators.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira


More information about the logback-dev mailing list