Logging in J2ME

后端 未结 8 2203
不知归路
不知归路 2020-12-08 16:25

What logging solutions exist for j2me?

I\'m specifically interested in easily excluding logging for \"release\" version, to have a smaller package & memory foot

8条回答
  •  不思量自难忘°
    2020-12-08 17:01

    Using conditional compilation of the logger class does not solve the problem of completely removing logging statements because you will quite often log more than a simple string. You will look up variable values and then assemble them into strings, e.g.: WhateverLog.log( "Loaded " + someclass.size() + " foos" ).

    Now if you only leave out the body of WhateverLog.log (as shown in the accepted solution), you will still leave a lot of unnecessary code in, including String concatenation (and thus a StringBuffer creation). That's why you'd better use a byte code post processing tool like proguard (already mentioned). Proguard's -assumenosideeffects will allow its optimizer to remove not only the logging statements but also all code whose results would only be used by the logging call.

提交回复
热议问题