File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Log file created but datepattern is not getting appended

 
Pravin Sharma
Greenhorn
Posts: 11
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am using dailyRollingFileAppender for logger.i have configured it as follows

log4j.appender.fileAppender = org.apache.log4j.DailyRollingFileAppender
log4j.appender.fileAppender.File = .\\App_Error_Log.log
log4j.appender.fileAppender.DatePattern='.'yyyy-MM-dd
log4j.appender.fileAppender.Append = true
log4j.appender.fileAppender.layout = org.apache.log4j.PatternLayout
log4j.appender.fileAppender.layout.ConversionPattern =[%d{dd MM yy HH:mm:ss}] %-5p %C : %L - %m%n

it is creating new file but file name does not contains any date pattern that i defined.

Please help me.....
 
Tanzy Akhtar
Ranch Hand
Posts: 110
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Pravin,

By looking at the configuration file, What i feel is you need to create a log file
having current timestamp as file name.

If i am right, then you may use Timestamp File Appender.
The link is Code Snippet.

If i am wrong, then please elaborate your need.


Thanks,
Tanzy.
 
Carol Enderlin
drifter
Ranch Hand
Posts: 1364
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Pravin Sharma wrote:Hi,
I am using dailyRollingFileAppender for logger.i have configured it as follows

...

it is creating new file but file name does not contains any date pattern that i defined.

Please help me.....


It uses the date pattern to determine when to roll over and names the backup files with the date pattern. The "current" file is named without the data patter.
 
Pravin Sharma
Greenhorn
Posts: 11
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thks tanzy to help me,
you are right that i need to create file with current timestamp.but i want it to be created dynamically.
as i read on some docs,if i give file name and date pattern,file will be created with that file name appended with date as of date pattern.
so if you can tell me more about DailyRollingFileAppender,please tell.

 
Pravin Sharma
Greenhorn
Posts: 11
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi carol,

in my property file ,i mentioned date pattern as of i know.is there any data pattern for it.shall i have to configure in my case.
please suggest.
 
Tanzy Akhtar
Ranch Hand
Posts: 110
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Pravin,

I found out the problem in the configuration.

In windows/unix, folder/file name can not contain the ":" character.

So please replace all the occurances of : in conversion pattern.

I think it will help.

Thanks,
Tanzy.
 
Tanzy Akhtar
Ranch Hand
Posts: 110
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you got the solution?
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic