Uploaded image for project: 'Jackrabbit Content Repository'
  1. Jackrabbit Content Repository
  2. JCR-3564

Possible improvement: use logback's "default value for variables" functionality



    • Improvement
    • Status: Closed
    • Major
    • Resolution: Not A Problem
    • 2.6
    • None
    • jackrabbit-standalone
    • None


      In a recent message [1], a jackrabbit-standalone user complained about not being able to configure logging. The user was complaining about the logs being output into the file "jackrabbit.log_IS_UNDEFINED" . The UNDEFINED suffix is used by logback to indicate that the variable ${jackrabbit.log} was well, undefined. The logback.xml file shipping in jackrabbit-standalone-2.6.0.jar indeed makes use of this variable to define the output target of a FileAppender.

      After some investigation, in appears that prepareServerLog() method in Main [2] class sets this variable/system property (among other logging related system properties). Thus, I don't really understand how the ${jackrabbit.log} variable can be undefined as it should be defined by prepareServerLog() method.

      Having said that, I think it would be possible to get rid of the prepareServerLog() method altogether by using logback's "default value for variables" functionality [3]. The variable substitution capabilities of logback are inanely powerful. Variable names as well as default values can be nested, even multiple times.

      For example, the file property of the FileAppender named jackrabbit could be written as:


      If the $repo and ${jackrabbit.log} variables are not defined, the file property will be set to "jackrabbit/log/jackrabbit.log". Logback will automatically create missing folders if any. if you wish to use the fully qualified path for ${repo}, then you can set it as a system property and let logback perform the rest of the substitution.

      Similarly, the root level could be set to INFO by default, but still allow it to be overridden by setting ${log.level}:

      <root level="${log.level:-INFO}">

      I hope you find the above helpful,

      [1] http://markmail.org/message/mriltleg4an6yu4e
      [2] http://goo.gl/Lf3Ig
      [3] http://logback.qos.ch/manual/configuration.html#defaultValuesForVariables




            Unassigned Unassigned
            ceki@qos.ch Ceki Gülcü
            0 Vote for this issue
            1 Start watching this issue