|
|
Sponsor |
RE: Can I have time stamp in log file name?: msg#00062apache.logging.log4cxx.user
Hi,
I had
a similiar requirement at my work. We got around it by using the config system
property value substitution mechanism. It's not the best solution I'm sure, for
many reasons, but it worked for us.
To
give an example, the first time you configure and everytime
thereafter you want to change the filename, you have code to do as
follows:
Date now = new
Date();
System.setProperty("log4j.hours", new String(now.getHours())); System.setProperty("log4j.minutes", new String(now.getMinutes())); System.setProperty("log4j.seconds", new String(now.getSeconds()));
BasicConfigurator.resetConfiguration();
PropertyConfigurator.configure("log4j.properties"); The
contents of your log4j.properties file then looks something like
this:
log4j.rootLogger=INFO,
A1
.
log4j.appender.A1=org.apache.log4j.RollingFileAppender log4j.appender.A1.File=/home/log/Log_${log4j.hours}_${log4j.minutes}_${log4j.seconds}.txt log4j.appender.A1.MaxFileSize=100KB log4j.appender.A1.MaxBackupIndex=1 log4j.appender.A1.layout=org.apache.log4j.PatternLayout log4j.appender.A1.layout.ConversionPattern=%p %t %c - %m%n Cheers, Jess
Visit our website at http://www.ubs.com This message contains confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system. E-mail transmission cannot be guaranteed to be secure or error-free as information could be intercepted, corrupted, lost, destroyed, arrive late or incomplete, or contain viruses. The sender therefore does not accept liability for any errors or omissions in the contents of this message which arise as a result of e-mail transmission. If verification is required please request a hard-copy version. This message is provided for informational purposes and should not be construed as a solicitation or offer to buy or sell any securities or related financial instruments.
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: Can I have time stamp in log file name?, FabijanicA |
|---|---|
| Next by Date: | Re: Can I have time stamp in log file name?, Curt Arnold |
| Previous by Thread: | 0.9.8 build issue on RHEL3, jwert |
| Next by Thread: | Re: Can I have time stamp in log file name?, Curt Arnold |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
Free MagazinesCisco NewsReceive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business. subscribe Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field. subscribe The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business. subscribe Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company. subscribe Total Telecom Total Telecom is "The Economist of the communications industry". subscribe |
Home | sitemap
| advertise | OSDir is
an inevitable website.
|