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
> > >
> > >
> > 
> > 
> 
> 

Reply via email to