[logback-dev] [JIRA] Commented: (LBCORE-54) FileAppender to support FileNamePattern option

Chris Cheshire (JIRA) noreply-jira at qos.ch
Tue Sep 2 01:14:45 CEST 2008

    [ http://jira.qos.ch/browse/LBCORE-54?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=10700#action_10700 ] 

Chris Cheshire commented on LBCORE-54:

Sorry for the confusion, let me clarify this.

My configuration for the appender is :

  <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
    <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">

    <layout class="ch.qos.logback.classic.PatternLayout">
      <Pattern>%-25(%date{HH:mm:ss.SSS} [%thread]) %-5level %logger{10} - %msg%n</Pattern>

What I am suggesting is for there to be a FileNamePattern option for the RollingFileAppender (so FileAppender and its subclasses?) just like the option for the rolling policy. Basically where the File option exists, I would like a FileNamePattern to alternatively be used.

As it stands right now, when the app runs the directory structure of logs/yyyy/mm/dd is created (and left empty). Under the base logs directory, all logging goes to appname.log. If the application doesn't run past midnight (a small start-stop application for instance), then no rolling is performed and the file logs/appname.log just gets continually appended to each time the app is run (even if it is a new day).

I would like to create the log file in a dynamically created directory each time it starts, with something like the following simple configuration, or with a rolling file appender instead. 

  <appender name="FILE" class="ch.qos.logback.core.FileAppender">

    <layout class="ch.qos.logback.classic.PatternLayout">
      <Pattern>%-25(%date{HH:mm:ss.SSS} [%thread]) %-5level %logger{10} - %msg%n</Pattern>

This does not work - from the logback configurator I see :

16:06:03,698 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.FileAppender]
16:06:03,703 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [FILE]
16:06:03,715 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter at 26:22 - no applicable action for [FileNamePattern], current pattern is [[configuration][appender][FileNamePattern]]
16:06:03,721 |-ERROR in ch.qos.logback.core.FileAppender[FILE] - File option not set for appender [FILE].
16:06:03,721 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Popping appender named [FILE] from the object stack


> FileAppender to support FileNamePattern option
> ----------------------------------------------
>                 Key: LBCORE-54
>                 URL: http://jira.qos.ch/browse/LBCORE-54
>             Project: logback-core
>          Issue Type: Improvement
>          Components: Appender
>         Environment: Any
>            Reporter: Chris Cheshire
>            Assignee: Logback dev list
> It would be very useful if the base FileAppender supported the FileNamePattern option, the same as the rolling policy classes do for the RollingFileAppender. This will allow for log files to be created directly into a date based directory in the format of "logs/yyyy/MM/dd/appname.log".

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