| From | Sent On | Attachments |
|---|---|---|
| Pete Muir | Aug 17, 2009 10:04 am | |
| Ralph Goers | Aug 17, 2009 2:40 pm | |
| Pete Muir | Aug 18, 2009 6:37 am | |
| Ralph Goers | Aug 18, 2009 7:10 am | |
| 近藤 健 | Aug 18, 2009 9:59 am | |
| Pete Muir | Aug 19, 2009 8:30 am | |
| Ralph Goers | Aug 19, 2009 9:15 am | |
| Ceki Gulcu | Aug 19, 2009 11:17 am | |
| Pete Muir | Aug 19, 2009 11:20 am | |
| Pete Muir | Aug 19, 2009 11:29 am | |
| Ceki Gulcu | Aug 19, 2009 11:42 am | |
| Pete Muir | Aug 19, 2009 11:50 am | |
| Ceki Gulcu | Aug 19, 2009 12:38 pm | |
| Ralph Goers | Aug 19, 2009 1:42 pm | |
| Ceki Gulcu | Aug 19, 2009 1:57 pm | |
| Ceki Gulcu | Aug 19, 2009 2:14 pm | |
| Ralph Goers | Aug 19, 2009 2:20 pm | |
| Ralph Goers | Aug 19, 2009 2:31 pm | |
| Ceki Gulcu | Aug 19, 2009 2:40 pm | |
| 近藤 健 | Aug 20, 2009 8:21 am | |
| Ralph Goers | Aug 20, 2009 8:35 am | |
| Takeshi Kondo | Aug 20, 2009 10:06 am | |
| ralp...@dslextreme.com | Aug 20, 2009 10:20 am | |
| Ceki Gulcu | Aug 20, 2009 1:58 pm | |
| Ceki Gulcu | Aug 20, 2009 2:05 pm | |
| Takeshi Kondo | Aug 21, 2009 10:27 pm | |
| Takeshi Kondo | Aug 22, 2009 10:31 pm | .jar, .jar |
| Ralph Goers | Aug 23, 2009 8:20 am | |
| Takeshi Kondo | Aug 23, 2009 8:40 am | |
| Ceki Gulcu | Aug 23, 2009 10:38 am | |
| Takeshi Kondo | Aug 23, 2009 4:58 pm | |
| Ralph Goers | Aug 23, 2009 9:55 pm | |
| Ceki Gulcu | Aug 24, 2009 6:14 am | |
| Takeshi Kondo | Aug 24, 2009 10:02 am | |
| Ceki Gulcu | Aug 24, 2009 10:22 am | |
| Takeshi Kondo | Aug 24, 2009 11:05 am | |
| Ceki Gulcu | Aug 24, 2009 11:26 am | |
| Takeshi Kondo | Aug 24, 2009 12:36 pm | |
| Ceki Gulcu | Aug 24, 2009 12:56 pm | |
| Takeshi Kondo | Aug 24, 2009 1:15 pm | |
| Ceki Gulcu | Aug 24, 2009 1:24 pm | |
| Ralph Goers | Aug 24, 2009 1:32 pm | |
| Takeshi Kondo | Aug 24, 2009 2:02 pm | |
| Ceki Gulcu | Aug 25, 2009 1:31 am |
| Subject: | Re: [slf4j-dev] slf4j i8ln | |
|---|---|---|
| From: | Ralph Goers (rgo...@apache.org) | |
| Date: | Aug 23, 2009 9:55:49 pm | |
| List: | org.slf4j.dev | |
I found a few minutes to review the code this evening. There are several things I don't care for in this implementation: 1. While doable, plugging in new resolver implementations is kind of a pain. You have to create an I18NLogManager, create the custom resolvers and presumably new annotation resolvers, add them to the CompositeResolvers then add those to the manager. Finally a new I18nLoggerFactory has to be created taking the manager and setINSTANCE called. 2. The resolvers provide no mechanism for reloading the bundles if they are modified. Many environments want 24x7 up time and do not want to restart servers just to change message text. 3. The implementation only supports a single Locale - the default. 4. I dislike immensely having the log level in one property file and the message text in another. This is very error prone. If you want log levels then get rid of the property files and switch to using XML where the log level and message can be bound together. Of course, this runs the risk that the level might be different from one language to another. Another option - which makes far more sense to me - is to not even have a LogLevelResolver, just require the log level be defined in the enum and just use that. 5. Messages are always resolved in the writeLog method. This precludes the option of the message keys being written to a database so the message can be retrieved based on the user's locale or passing the message to different machines where it can be logged using a Locale appropriate for that environment. 6. If you really, really want to use ResourceBundle's then at least make Java 6 the minimum version and provide support for ResourceBundle.Control. However, since ResourceBundles don't provide support for reloading I'd avoid using them at all. 7. It seems very strange to have the LogLevel enum have log methods and that writeLog is actually calling them. 8. The callerData is going to be useless since the LogLevel enum is just using the standard SLF4J apis. Instead, the Logger needs to extend org.slf4j.ext.LoggerWrapper and actually log from that class. 9. The format of the LogMessages enum is:
public enum LogMessages {
@Error("error message {}") // The log level is bound to Error. TEST0001,
@Message("waring message {}") // The log level is not specified. TEST0002
}
a. why would you want to allow a log level to not be specified? (See item 4 above). It is now possible to not specify the level in the properties file and not specify it as an annotation. If that happens then the level will be info since that is what is hardcoded in I18NLoggerFactory. What is more annoying is that I can call logger.warn and generate an info level message. b. Other than showing that you know how to use annotations I don't see what the benefit is over doing something like:
public enum LogMessages { private final LogLevel level; private final String message;
public LogMessages(LogLevel lvl, String msg) { level = lvl; message = msg; }
public LogLevel getLogLevel() { return level }; public String getMessage() { return message };
TEST0001(LogLevel.ERROR, "error message {}"); TEST0002(LogLevel.WARN, "warning message {}"};
}
I only spent about an hour looking at this so this may not be the complete set of issues I might find.
In short, this implementation is not very general purpose as it only supports a single use case.
Ralph
On Aug 22, 2009, at 10:32 PM, Takeshi Kondo wrote:
<slf4j-i18n-1.5.9-SNAPSHOT.jar><slf4j-i18n-1.5.9-SNAPSHOT-sources.jar>
I've developed initial thought of SLF4j's i18n extension. It was committed to my branch (http://github.com/takeshi/slf4j/tree/master ).
I've implemented 4 features as follows.
1. Logger interface using enum. @see org.slf4j.i18n.I18NLogger
2. Extension point to bind log id's enum to log message and level. @see org.slf4j.i18n.spi.LogLevelResolver @see org.slf4j.i18n.spi.LogMessageFormatResolver
3. Resolving log message and log level from Annotation associated from log id's enum. @see org.slf4j.i18n.impl.AnnotationLogLevelResolver @see org.slf4j.i18n.impl.AnnotationMessageFormatResolver
4. Resolving log message and log level from ResourceBundle associated with log id's enum. @see org.slf4j.i18n.impl.ResourceBundleLogLevelResolver @see org.slf4j.i18n.impl.ResourceBundleMessageFormatResolver
For example:
---- Log Message Definition
---- public enum LogMessages {
@Error("error message {}") // log level is bound to Error. TEST0001,
@Message("waring message {}") // log level is not specified. TEST0002
}
---- Logging
----
public static void main(String[] args) { I18NLogger logger = I18NLoggerFactory.getLogger(LogMain.class);
// write to error log , because LogMessages.TEST0001 is bound to Error level. logger.log(LogMessages.TEST0001, "xxxx"); logger.log(LogMessages.TEST0001, new NullPointerException());
// write log as error level. logger.error(LogMessages.TEST0002, "xxxx"); // write log as warn level. logger.warn(LogMessages.TEST0002, new NullPointerException()); }
Takeshi Kondo
_______________________________________________ dev mailing list de...@slf4j.org http://www.slf4j.org/mailman/listinfo/dev
_______________________________________________ dev mailing list de...@slf4j.org http://www.slf4j.org/mailman/listinfo/dev






.jar, .jar