×
Namespaces

Variants
Actions

Talk:Logging with Microlog in Java ME

From Nokia Developer Wiki
Jump to: navigation, search

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

Hi,

I 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
       	PropertyConfigurator.configure("/microlog_file.properties");

       	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 :

  1. 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.

Thanks

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

Hamishwillee - Please don't spam everywhere

Hi Ekagga

If may make sense to post in multiple places - but I suggest that you post once, then link to the detail in the other place from subsequent posts. You might want to raise this on the Java ME discussion boards and link to here.

Regards

Hamish

hamishwillee (talk) 03:49, 4 October 2013 (EEST)

 
×