Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries. Thanks for all your past and future contributions.

Talk:Microlog - a Log4j-based tool for Java ME

From Wiki
Jump to: navigation, search

Featured article, October 11th 2009 (week 42)

Ekagga Technologies - Problem while integrating logger for s40 device Nokia Asha 501

am using Nokia Asha SDK 1.0. I am trying to integrate microlog to log into file using configuration file but i got the following error

jarFileName is file:///usr/_memory_card/Midlets/HelloWorld.jar java.lang.NoClassDefFoundError: net/sf/microlog/core/LoggerFactory

  • java.lang.Class.invoke_clinit(), bci=0
  • java.lang.Class.initialize(), bci=125
  • java.lang.Class.forName(), bci=0
  • com.sun.midp.main.CldcMIDletLoader.newInstance(), bci=1
  • com.sun.midp.midlet.MIDletStateHandler.createMIDlet(), bci=63
  • com.sun.midp.midlet.MIDletStateHandler.createAndRegisterMIDlet(), bci=17
  • com.sun.midp.midlet.MIDletStateHandler.startSuite(), bci=24
  • com.sun.midp.main.AbstractMIDletSuiteLoader.startSuite(), bci=38
  • com.sun.midp.main.CldcMIDletSuiteLoader.startSuite(), bci=5
  • com.sun.midp.main.AbstractMIDletSuiteLoader.runMIDletSuite(), bci=151
  • com.sun.midp.main.AppIsolateMIDletSuiteLoader.main(), bci=26

Here is my code :

import javax.microedition.midlet.MIDlet; import javax.microedition.lcdui.*;
import net.sf.microlog.core.Logger; import net.sf.microlog.core.LoggerFactory; import net.sf.microlog.core.PropertyConfigurator;
public class HelloWorldMIDlet extends MIDlet implements CommandListener { private Form form; private Command exitCommand; private Command logCommand;
// A logger instance for this class
private static final Logger log = LoggerFactory.getLogger(HelloWorldMIDlet.class);
protected void startApp() {
// Configure Microlog for using FileAppender
PropertyConfigurator.configure("/");"FileAppender set!");"Starting app..."); form = new Form("Hello, world!"); logCommand = new Command("Log", Command.SCREEN, 1); exitCommand = new Command("Exit", Command.EXIT, 1); form.setCommandListener(this); form.addCommand(logCommand); form.addCommand(exitCommand); Display.getDisplay(this).setCurrent(form); }
protected void destroyApp(boolean arg0) {"Closing app..."); LoggerFactory.shutdown(); }
protected void pauseApp() {}
public void commandAction(Command c, Displayable d) { if (c == logCommand) { // logging into a file must be done in a separate Thread in Nokia Asha 501. new Thread() { public void run() {"Logging..."); } }.start(); } if (c == exitCommand) this.notifyDestroyed(); } }

and I have saved the file in /res folder of my project with following contents :

This is a simple Microlog configuration file microlog.level=DEBUG microlog.appender=FileAppender microlog.appender.FileAppender.filename=MemoryCard/micrologtestlog.txt microlog.formatter=net.sf.microlog.core.format.PatternFormatter microlog.formatter.PatternFormatter.pattern=[%P] %c %d (%r): %m %T

If anyone have clue the post it please.


Ekagga Technologies (talk) 17:08, 3 October 2013 (EEST)