> -----Original Message----- > From: Hewitt, Simon C. (Contractor) [mailto:[EMAIL PROTECTED] > Sent: 05 May 2005 14:00 > To: Log4NET Dev > Subject: RE: Header/Footer doesn't recognize patterns? > > Is there any way of evaluating it at the time of logging > rather than configuration time? > (I wanted to put a timestamp in the header and the footer)
The default implementation in LayoutSkeleton is to store a string for the header and footer values. Therefore it is not possible to store a PatternString object for the header and footer values, which is why currently the PatternString is evaluated into a static string at configuration time. You can subclass the PatternLayout and add new HeaderPattern and FooterPattern properties which store PatternString objects. You can then override the Header and Footer properties to evaluate the patterns when the values are requested. The layout's Header and Footer values can be requested at anytime by the appender. For example the FileAppender requests the header when it opens the output file. The header is written immediately regardless of when the first event is appended to the file. As the FileAppender opens the output file at config time the timestamp generated at Header request time would be very similar to the value of a PatternString evaluated at config time. As the Footer is written later this would show a big difference when compared with the config time. > BTW Two minor items in PatternString.cs > - the s_globalRulesRegistry declaration is for 10 items but > 13 are then added > - the class documentation has a typo on line 42 ("does does...") Fixed, thanks. > > Also, whilst I'm writing to you, what is the reason for 'hiding' the > other built-in levels such as Trace, Verbose, Notice, Emergency etc.? > I've written a LogEx class which:- > 1) adds all of the hidden' levels > 2) adds a CustomLevel(Level level, object message) set of methods > 3) adds a new level 'public static Level DumpLevel = new Level(5000, > "DUMP");' so I can have an extra level below Trace > > All this works fine but I'm intrigued as to why ILog is implemented as > it is. The ILog interface is designed to provide a limited set of functionality which meets the needs of most logging scenarios. If you have specific requirements then it will not be suitable. The ILog interface and the LogManager constitute an extension to log4net, by that I mean that it is an adapter between the calling application and the log4net framework. It is possible to have many of these extensions simultaneously providing specialised APIs over the same set of loggers. The ILog extension is built-in to the framework, but there are 2 example extensions that are included in the log4net download at extensions\net\1.0. The log4net.Ext.Trace extension adds support for the Trace level. The log4net.Ext.EventID extension takes an additional EventID int with each of the logging methods, this is stored in the LoggingEvent and used by the EventLogAppender. The recommended way of implementing a specialised logging API is to write an extension. Cheers, Nicko > > Cheers > Simon > > -----Original Message----- > From: Nicko Cadell [mailto:[EMAIL PROTECTED] > Sent: 16 April 2005 20:44 > To: Log4NET Dev > Subject: RE: Header/Footer doesn't recognize patterns? > > > You can use a PatternString in the header or footer, this will be > evaluated at configuration time. For example: > > <header type="log4net.Util.PatternString" value="LOG START > processid=%processid" /> > > (PatternString was introduced in log4net 1.2.9) > > Nicko > > > -----Original Message----- > > From: Hewitt, Simon C. (Contractor) [mailto:[EMAIL PROTECTED] > > Sent: 14 April 2005 13:44 > > To: log4net-dev@logging.apache.org > > Subject: Header/Footer doesn't recognize patterns? > > > > Maybe I'm missing something but patterns I put into the > > header string are logged verbatim. > > Any chance of allowing patterns to be used in headers and footers?? > > > > Simon Hewitt > > BP Shipping (Contractor) > > Mobile - 07973 205241 > > -- > > (There are 10 kinds of people - those who understand binary > > and those who don't) > > > > >