You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by "K P (JIRA)" <ji...@apache.org> on 2016/06/13 09:22:21 UTC
[jira] [Commented] (LOG4J2-1185) Ability to change the fileName
dynamically in RollingFileAppender
[ https://issues.apache.org/jira/browse/LOG4J2-1185?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15327047#comment-15327047 ]
K P commented on LOG4J2-1185:
-----------------------------
This was indeed possible in log4j 1.x
(actually, we also rely on that, due to the log file name structure used in all our applications (various technologies and languages), and because tools, users, etc... (specs!) rely on it.)
The filename is tightly integrated (privately) into the FileManager classes, without API to change it. Only ugly hacks with reflection may work ( http://stackoverflow.com/questions/30059333/log4j2-rolling-appender-filename-sliding-according-to-pattern ), ... provided the internal implementation of log4j2 doesn't change and would make even this hack entirely impossible.
To allow more users to make a transition of log4j 1.x > log4j2, this feature would be more than welcome.
> Ability to change the fileName dynamically in RollingFileAppender
> -----------------------------------------------------------------
>
> Key: LOG4J2-1185
> URL: https://issues.apache.org/jira/browse/LOG4J2-1185
> Project: Log4j 2
> Issue Type: New Feature
> Components: Appenders
> Affects Versions: 2.1
> Reporter: Dhwaneet Bhatt
> Assignee: Ralph Goers
>
> Right now RollingFileAppender rolls over the current file with fileName to the one generated by FilePattern. However, logging always continues in the same fileName i.e. fileName once created cannot be changed.
> Property Substitution is only once during initialization, fileName is never changed after RollingFileManager is initialized. The RollingFileManager is very tightly tied up to the fileName attribute.
> Consider that I want to name my log files like this using RollingFileAppender:
> mylog-2015-10-30.log
> mylog-2015-10-29.log
> mylog-2015-10-28.log
> There is no good way to achieve this, because even after rolling over the file, the fileName would still remain the same. If I initialized my fileName using $\{date:yyyy-MM-dd\}, date would be substituted only once during initialization and it would never change, always continue to log in the same log file (until I restart my application).
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org