1

I want to create a log file for log4j using FileAppender.

For e.g if log file is : /home/jj/socket/socket.log

I want log as:

/home/jj/socket/socket_YYYYMMDDhhmm.log

or

/home/jj/socket/socket_YYYYMMDD.log
nsgulliver
  • 12,655
  • 23
  • 43
  • 64
user656189
  • 139
  • 8
  • 17
  • 1
    See this SO question and it's answer: http://stackoverflow.com/questions/192456/setting-a-log-file-name-to-include-current-date-in-log4j – no.good.at.coding Apr 18 '11 at 22:12
  • I looked at it before asking this question. It basically suggests using: RollingFileAppender/DailyRollingFileAppender, which I cannot use in my use case. – user656189 Apr 18 '11 at 23:51
  • Fine. Then set your own filename when opening FileAppender. You can create them programmatically, you know. And if creating FileAppender programmatically is no good, create your own subclass of it, and set the filename. – MJB Apr 23 '11 at 20:05

0 Answers0