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

From Nokia Developer 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

  • com.nokia.example.HelloWorldMIDlet.<clinit>(HelloWorldMIDlet.java:16)
  • 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 :

package com.nokia.example;
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
log.info("FileAppender set!");
log.info("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) { log.info("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() { log.info("Logging..."); } }.start(); } if (c == exitCommand) this.notifyDestroyed(); } }

and I have saved the microlog_file.properties 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)


Was this page helpful?

Your feedback about this content is important. Let us know what you think.


Thank you!

We appreciate your feedback.