As posted earlier, the datetime part is treated specially when rolling files while the other parts are assumed to be static. This is much easier to handle when having to count rolls and such without keeping a log in a persistent location (which, by the way, I believe will be the future development).
Cheers 2013/7/26 Howe, Peter L <[email protected]> > Drat, you are correct. I got two files:**** > > ** ** > > 20130726_6456_27_MyApplication.log**** > > 20130726_6456_26_MyApplication.log**** > > ** ** > > L**** > > ** ** > > Peter**** > > ** ** > > ** ** > > *From:* Dominik Psenner [mailto:[email protected]] > *Sent:* Friday, July 26, 2013 9:44 AM > > *To:* 'Log4NET Dev' > *Subject:* AW: File naming**** > > ** ** > > Increase your computers local time by 24 hours and observe. If I’m not > wrong you’ll see that the “20130726_6600_” part won’t change because it > is evaluated only once in the appenders lifetime.**** > > ** ** > > Dominik**** > > ** ** > > *Von:* Howe, Peter L [mailto:[email protected] <[email protected]>] > *Gesendet:* Freitag, 26. Juli 2013 15:38 > *An:* Log4NET Dev > *Betreff:* RE: File naming**** > > ** ** > > ** ** > > I’m almost there, but I don’t know enough about the code to see if it > would roll properly. With this configuration:**** > > ** ** > > <file type="log4net.Util.PatternString" **** > > value="C:\temp\logs\%date{yyyyMMdd}_%processid_" /> **** > > ** ** > > <staticLogFileName value="false"/>**** > > <appendToFile value="true"/>**** > > <rollingStyle value="Date"/>**** > > ** ** > > <datePattern value="dd'_MyApplication.log'"/> **** > > ** ** > > I get files that are named like:**** > > ** ** > > 20130726_6600_26_MyApplication.log**** > > 20130726_6744_26_MyApplication.log**** > > etc.**** > > ** ** > > I had to leave the “dd” in the datePattern so it had something to roll on, > but I have not tried running the test application overnight to see what > really happens at midnight…**** > > ** ** > > Peter**** > > ** ** > > ** ** > > ** ** > > ** ** > > ** ** > > *From:* Dominik Psenner [mailto:[email protected] <[email protected]>] > *Sent:* Thursday, July 25, 2013 2:23 AM > *To:* 'Log4NET Dev' > *Subject:* AW: File naming**** > > ** ** > > You found a workaround. Interesting. J However, you won’t get the date as > a prefix for %processid. I’m posting the code responsible for calculating > the filename in the RollingFileAppender which should explain why what’s the > case:**** > > ** ** > > --- QUOTE ---**** > > protected string GetNextOutputFileName(string fileName)**** > > {**** > > if (!m_staticLogFileName) **** > > {**** > > fileName = fileName.Trim();**** > > if (m_rollDate)**** > > {**** > > fileName = CombinePath(fileName, m_now.ToString(m_datePattern, > System.Globalization.DateTimeFormatInfo.InvariantInfo));**** > > }**** > > ** ** > > if (m_countDirection >= 0) **** > > {**** > > fileName = CombinePath(fileName, "." + m_curSizeRollBackups);**** > > }**** > > }**** > > return fileName;**** > > }**** > > --- /QUOTE ---**** > > ** ** > > where CombinePath behaves like this:**** > > ** ** > > --- QUOTE ---**** > > private string CombinePath(string path1, string path2)**** > > {**** > > string extension = Path.GetExtension(path1);**** > > if (m_preserveLogFileNameExtension && extension.Length > 0)*** > * > > {**** > > return Path.Combine(Path.GetDirectoryName(path1), > Path.GetFileNameWithoutExtension(path1) + path2 + extension);**** > > }**** > > else**** > > {**** > > return path1 + path2;**** > > }**** > > }**** > > --- /QUOTE ---**** > > ** ** > > Therefore there are various restrictions involved with how and where the > date can be put into the filename.**** > > ** ** > > Currently there’s no way of changing this since any way to improve this > would require to change the public API (the way the RFA is configured) and > thus we will try to fix that filename trouble once and for all with the > rewrite of the RollingFileAppender. I can imagine that there won’t be a > <datePattern> configuration anymore, but everything will be put into the > <file> tag where one will be able to use something like %date{format}. At > least that’s what I believe would be the best since that allows people to > put the date portion into directory names which was often requested but so > far has been impossible to do. And that way we allow even fancier stuff to > happen in the <file> tag. J Even though this will complicate the rolling > significantly and there are a lot of cases that need to be taken care of.* > *** > > ** ** > > Cheers**** > > The information contained in this message may be privileged, confidential > and protected from disclosure. If the reader of this message is not the > intended recipient, or an employee or agent responsible for delivering this > message to the intended recipient, you are hereby notified that any > dissemination, distribution or copying of this communication is strictly > prohibited. If you have received this communication in error, please notify > your representative immediately and delete this message from your computer. > Thank you.**** > -- Dominik Psenner ## OpenPGP Key Signature ################################# # Key ID: B469318C # # Fingerprint: 558641995F7EC2D251354C3A49C7E3D1B469318C # ##########################################################
