This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Other Open Source Projects and the fly likes Log file created but datepattern is not getting appended Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "Log file created but datepattern is not getting appended" Watch "Log file created but datepattern is not getting appended" New topic
Author

Log file created but datepattern is not getting appended

Pravin Sharma
Greenhorn

Joined: Jun 18, 2009
Posts: 11
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

Joined: Jul 19, 2009
Posts: 110
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.


Roll with punchers, there is always tomorrow.
Techie Blog -- http://jtanzy.blogspot.com/
Carol Enderlin
drifter
Ranch Hand

Joined: Oct 10, 2000
Posts: 1364
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

Joined: Jun 18, 2009
Posts: 11
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

Joined: Jun 18, 2009
Posts: 11
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

Joined: Jul 19, 2009
Posts: 110
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

Joined: Jul 19, 2009
Posts: 110
Did you got the solution?
 
GeeCON Prague 2014
 
subject: Log file created but datepattern is not getting appended