I found these sentances helpful: " The goal of this class is to Format a LoggingEvent as a string. The results depend on the conversion pattern. " http://tinyurl.com/e3nd3 http://logging.apache.org/log4net/release/sdk/log4net.Layout.PatternLayout.html
" Unlike the PatternLayout however the PatternString does does not render properties of a specific LoggingEvent but of the process in general. " http://tinyurl.com/dghqs http://logging.apache.org/log4net/release/sdk/log4net.Util.PatternString.html I used a PatternString in the header and footer nodes because I didn't have a LoggingEvent to pull information out of. PatternString and PatternLayout have some overlap with things like %date/%d and %newline/%n. That's where I got confused. I thought I could use %n and %d as shortcuts in a PatternString but you can't, you need to use the full %date and %newline patterns. Line 168 of log4net.Util.PatternStringConverters.DatePatternConverter confirms that the %date pattern of PatternString uses the current date/time: m_dateFormatter.FormatDate(DateTime.Now, writer); Had that been a PatternLayout, it would have used loggingEvent.TimeStamp for its DateTime value. Hope that helps, Ron --- Russell Haley <[EMAIL PROTECTED]> wrote: > Can I ask you where you found that? I was looking REALLY hard for > that. > It's upsetting when I can't find things... Now where did I put my > config > file? > > Russ > > Ron Grabowski wrote: > > >This is what you want: > > > ><header value="[BEGIN LOGGING AT %date]%newline" > >type="log4net.Util.PatternString" /> > > > ><footer value="[END LOGGING AT %date]%newline" > >type="log4net.Util.PatternString" /> > > > >My example of using a custom PatternConverter is overkill. You don't > >need to do that. Same thing for my idea about having a %now pattern; > >PatternString's %date pattern already does that. > > > >I learn something new every time I read the docs :-) > > > >- Ron > > > >--- Russell Haley <[EMAIL PROTECTED]> wrote: > > > > > > > >>lol, my bad. That's probably what I did too... :-} > >> > >>Cheers > >>Russ > >> > >>-----Original Message----- > >>From: Ron Grabowski [mailto:[EMAIL PROTECTED] > >>Sent: 15-Jun-05 12:19 PM > >>To: Log4NET User > >>Subject: RE: Date Time in Header Footer > >> > >> > >>The %d pattern applies to the timestamp of the log message. You're > >>essentially wanting to print out what time log4net was configured. > >>Its > >>my understanding that the header is written before any messages > come > >>through the pipeline and the footer is written during the shutdown > >>process. I could be wrong. > >> > >>As soon as I configure log4net, I record this log message: > >> > >> log.Info("Application Started."); > >> > >>In my application's shutdown code I record this log message: > >> > >> log.Info("Application Ended."); > >> > >>So I can easily see when my application has recycled. > >> > >>- Ron > >> > >>--- Russell Haley <[EMAIL PROTECTED]> wrote: > >> > >> > >> > >>>hmmm... I could have sworn I got something like this working in a > >>>logger I > >>>wrote for a different company... The solution would have had to be > >>>really > >>>simple because I didn't know JS about L4N (not that my knowledge > of > >>>L4N has > >>>changed really...) and just used the default config info from one > >>> > >>> > >>of > >> > >> > >>>the > >>>examples - not including this one modification. > >>> > >>>Anyway, thanks once again Ron! > >>> > >>>Russ > >>> > >>>-----Original Message----- > >>>From: Ron Grabowski [mailto:[EMAIL PROTECTED] > >>>Sent: 15-Jun-05 11:39 AM > >>>To: Log4NET User > >>>Subject: Re: Date Time in Header Footer > >>> > >>> > >>>You could write your own pattern converter to expose the a > DateTime > >>>object: > >>> > >>><header type="log4net.Util.PatternString"> > >>> <converter> > >>> <name value="dateTimeNow" /> > >>> <type value="Company.Project.Logging.DateTimePatternConverter, > >>>Company.Project" /> > >>> </converter> > >>> <conversionPattern value="[BEGIN LOGGING AT > >>> > >>> > >>%dateTimeNow{hh:mm}]%n" > >> > >> > >>>/> > >>></header> > >>> > >>>I agree that that's a lot of code for just wanting to print out > the > >>>current date and time :-/ > >>> > >>>Perhaps a built-in pattern called %now could be added that accepts > >>> > >>> > >>a > >> > >> > >>>DateTime format: > >>> > >>> %now{d} > >>> %now{hh:mm:ss} > >>> > >>>- Ron > >>> > >>>--- Russell Haley <[EMAIL PROTECTED]> wrote: > >>> > >>> > >>> > >>>>I'm trying ot insert the date and time in the header footer > >>>> > >>>> > >>blocks > >> > >> > >>>of > >>> > >>> > >>>>my > >>>>log. I did a search on the mailing list but didn't find anything. > >>>> > >>>>I have tried %d, %date and \d without any success. > >>>> > >>>> <param name="Header" value="[BEGIN LOGGING AT \d]\r\n" /> > >>>> <param name="Footer" value="[END LOGGING AT \d]\r\n" /> > >>>> > >>>>Suggestions? > >>>> > >>>>Thanks! > >>>> > >>>>Russ > >>>> > >>>> > >>>> > >>>> > >>> > >>> > >> > >> > > > > > > > > > > > >
