log4j2me
log4j2me是用于J2ME 平台上的log4j。当把你的代码移到J2SE/J2EE平台上时,不需要对代码进行改变,只需把log4j2me.jar替换掉log4j jar文件。与log4j所不同的是不能在j2me环境中使用log4j.properties文件来配置log4j,但可以从 JAD文件读取配置。还有其它在J2ME平台中的不同之处,log4j2me都提供了相应的解决方案。
log4j2me is log4j for j2me platform. It is an open source contribution from Witmate.
It is compatible with Log4J and executable on J2ME platform. When your code move to J2SE/J2EE platform, you need NOT change your code, just replace log4j2me.jar with standard log4j jar file.
Differentiations with original log4j
Limits by j2me platform:
- j2me can't write to file. So can't set file name directly in FileAppender
- j2me can't read file. So can't read configuration from file directly in PropertyConfigurator. But it is possible to get configuration from JAD file.
- j2me only can print stack track into standard error output. So can't get stack in LoggingEvent, LocationInfo
- J2ME has not java.text package, so %d parameter just use log4j date formatters.
- LEVEL_CONVERTER does not work in PatternParser
- MESSAGE_CONVERTER(RenderMessage) does not work in PatternParser
- Fully qualified name of the calling category class (fqnOfCategoryClass) is same as category name in LoggingEvent.
- These parameters of pattern do not work: %X, %F, %M, %L, %l, and log out a question mark.
Extensions for j2me platform
- Configure by JAD file
- j2me can't get property list, so a "log4j.categories" property key to list all category names is added into configuration properties. Separator is comma, e.g., log4j.categories: classA,classB
- line.separator system property does not exist in J2ME default, LINE_SEP of log4j2me is LF(13) in Layout. It is configurable with LINE_SEP and LINE_SEP_LEN parameetr in Layout
- MIDLet form appender: Output log to a MIDLet form.
- New form appender is log4j2me.util.FormAppender.
- Optional handler of this appender is Title, this title is MIDLet form title.
- Configure example
log4j.appender.LOGFORM = log4j2me.util.FormAppender
log4j.appender.LOGFORM.Title = mylog4j2me