[slf4j-dev] slf4j i8ln

Ralph Goers rgoers at apache.org
Sun Aug 23 17:21:16 CEST 2009


I'm out of town on vacation right now so I might not get a chance to  
review this for a couple of days. But I'd like to provide my feedback  
before anything is incorporated.

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
> dev at slf4j.org
> http://www.slf4j.org/mailman/listinfo/dev




More information about the slf4j-dev mailing list