[JIRA] Created: (LBCORE-54) FileAppender to support FileNamePattern option

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

[ http://jira.qos.ch/browse/LBCORE-54?page=com.atlassian.jira.plugin.system.is... ] Ceki Gulcu commented on LBCORE-54: ---------------------------------- The easiest way to accomplish this is to sub-class TimeBasedRolling so that the isTriggeringEvent() method always returns false.
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

[ http://jira.qos.ch/browse/LBCORE-54?page=com.atlassian.jira.plugin.system.is... ] Ceki Gulcu commented on LBCORE-54: ---------------------------------- Chris, The way the issue is described here is different than described in message [1] on the logback-user mailing list. In that message, you were using a RollingFileAppender. More specifically, the FileNamePattern does not support creation of directories within the date token. Adding support for this feature should go along way in solving the problem described initially in [1]. [1] http://www.qos.ch/pipermail/logback-user/2008-August/000504.html
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

[ http://jira.qos.ch/browse/LBCORE-54?page=com.atlassian.jira.plugin.system.is... ] 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"> <File>appname.log</File> <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> <FileNamePattern>logs/%d{yyyy/MM/dd/}appname.log</FileNamePattern> </rollingPolicy> <layout class="ch.qos.logback.classic.PatternLayout"> <Pattern>%-25(%date{HH:mm:ss.SSS} [%thread]) %-5level %logger{10} - %msg%n</Pattern> </layout> </appender> 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"> <FileNamePattern>logs/%d{yyyy/MM/dd/}appname.log</FileNamePattern> <layout class="ch.qos.logback.classic.PatternLayout"> <Pattern>%-25(%date{HH:mm:ss.SSS} [%thread]) %-5level %logger{10} - %msg%n</Pattern> </layout> </appender> 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@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 Chris
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

[ http://jira.qos.ch/browse/LBCORE-54?page=com.atlassian.jira.plugin.system.is... ] Chris Cheshire edited comment on LBCORE-54 at 9/2/08 1:36 AM: -------------------------------------------------------------- Sorry for the confusion, let me clarify this. My configuration for the appender is : <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> <File>appname.log</File> <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> <FileNamePattern>logs/%d{yyyy/MM/dd/}appname.log</FileNamePattern> </rollingPolicy> <layout class="ch.qos.logback.classic.PatternLayout"> <Pattern>%-25(%date{HH:mm:ss.SSS} [%thread]) %-5level %logger{10} - %msg%n</Pattern> </layout> </appender> 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"> <FileNamePattern>logs/%d{yyyy/MM/dd/}appname.log</FileNamePattern> <layout class="ch.qos.logback.classic.PatternLayout"> <Pattern>%-25(%date{HH:mm:ss.SSS} [%thread]) %-5level %logger{10} - %msg%n</Pattern> </layout> </appender> 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@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 Chris Edit: There was something in my code that was creating the date based directory structure for another purpose (saving downloaded data files). This created some of the confusion above. I see now with this disabled that logback is not creating any directories at all. was (Author: krustyfur): Sorry for the confusion, let me clarify this. My configuration for the appender is : <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> <File>appname.log</File> <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> <FileNamePattern>logs/%d{yyyy/MM/dd/}appname.log</FileNamePattern> </rollingPolicy> <layout class="ch.qos.logback.classic.PatternLayout"> <Pattern>%-25(%date{HH:mm:ss.SSS} [%thread]) %-5level %logger{10} - %msg%n</Pattern> </layout> </appender> 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"> <FileNamePattern>logs/%d{yyyy/MM/dd/}appname.log</FileNamePattern> <layout class="ch.qos.logback.classic.PatternLayout"> <Pattern>%-25(%date{HH:mm:ss.SSS} [%thread]) %-5level %logger{10} - %msg%n</Pattern> </layout> </appender> 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@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 Chris
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

[ http://jira.qos.ch/browse/LBCORE-54?page=com.atlassian.jira.plugin.system.is... ] Ceki Gulcu closed LBCORE-54. ----------------------------
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 Fix For: 0.9.10
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

[ http://jira.qos.ch/browse/LBCORE-54?page=com.atlassian.jira.plugin.system.is... ] Ceki Gulcu resolved LBCORE-54. ------------------------------ Fix Version/s: 0.9.10 Resolution: Fixed Given that as of version 0.9.10, logback creates missing directories, I think that the following configuration file will do what you want. Note that you do not need the "File" property. It will be guessed by the "FileNamePattern". <configuration> <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> <FileNamePattern>logFile.%d{yyyy/MM/dd}.log</FileNamePattern> </rollingPolicy> <layout class="ch.qos.logback.classic.PatternLayout"> <Pattern>%-4relative [%thread] %-5level %logger{35} - %msg%n</Pattern> </layout> </appender> <root level="debug"> <appender-ref ref="FILE" /> </root> </configuration> If you append ".zip" or ".gz" to the end of FileNamePattern, then rolled over files will be compressed as well. Note that the current log file will be in plain text (not compressed) for convenient access. Example: <FileNamePattern>logFile.%d{yyyy/MM/dd}.log.zip</FileNamePattern> I am closing this issue as "Resolved". If the above explanation does not meet your needs, please create a new issue which will not carry the confusing baggage of the present issue (LBCORE-54).
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 Fix For: 0.9.10
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
participants (2)
-
Ceki Gulcu (JIRA)
-
Chris Cheshire (JIRA)