It is also worth mentioning that, unlike log4j, in log4net the user does not interact with the Logger directly but with a wrapper. The Logger (ILogger) has a Log method that is used to log all the messages. The wrapper LogImpl (implements ILog) has all the Debug/Info/Warn/Error methods which forward the log call to the Logger method. The LogImpl contains the Format methods. If a use wants a different format implementation they can write their own wrapper with user callable methods.
Nicko > -----Original Message----- > From: Curt Arnold [mailto:[EMAIL PROTECTED] > Sent: 19 March 2006 00:32 > To: log4net-dev@logging.apache.org > Subject: Logging formatter in log4j sandbox > > I'm sure the timing sucks, but since the scuttling of the > 1.2.10 release involves formatting log messages and I have > recently been doing some things in the log4j sandbox, I > thought that I would bring that work to your attention. The > project can be checked out from > http://svn.apache.org/repos/asf/logging/sandbox/log4j/formatter. > > One of the problems with adding formatting to the Logger > class in log4j is that there are several widely used > formatting conventions: > java.text.MessageFormat has been in Java for quite some time, > java.util.Formatter was just added in JDK 1.5 (similar to C's > sprintf) and the UGLI/SLF4J effort added a syntax similar but > distinct to MessageFormat > (org.apache.log4j.helpers.MessageFormatter). Currently the > log4j code uses both java.text.MessageFormat (in the l7dlog > methods) and o.a.l.helpers.MessageFormatter (in the > debug(String fmt, ...) methods. > > The sandbox effort intention was to remove formatting from > the Logger class and to allow the user to pick the formatter > of their choice, while still being able to bypass argument > boxing, array creation and formatting on calls below the > threshold. The formatter project adds three static classes > LogMF, LogSF and LogF which log using the > java.text.MessageFormat, UGLI/SLF4J formatter and > java.util.Formatter respectively. In use the code would look like: > > LogMF.debug(logger, "User {0} logged out after {1} seconds", > username, duration); > > The original discussion can be read at http://marc.theaimsgroup.com/? > l=log4j-dev&m=113704872508753&w=2 > > I don't know the pattern syntax of the .NET formatter in use. > If it is similar to one of the Java formatters, then I would > use the corresponding class name. Otherwise, I would choose > a slightly different name in case we ever wanted to emulate > one of the Java formatters in .NET (actually, you might > already be able to use java.text.MessageFormat from J#). > > p.s. I had intended to add ResourceBundle variants of the > methods with signatures like: > > static void debug(Logger logger, ResourceBundle bundle, > String fmtKey, ...); > > > >