Search code examples
java-melwuit

How to Log a statement in j2me?


I developed an application in j2me, it is executing successfully. In future, if there is any issue in my statements, I want to debug my application. I know that, I can use System.out.println() but I want to log a statement, how can I do it in j2me? if possible provide me a sample code?


Solution

  • Simply

    public static void logToConsole(String str) {

         System.out.println(str);
    

    }

    Declare it in your utility class and use it.

    If you want to get a screen logger put your messages in it and display it on the canvas.

    //Vector which will hold your logs

    private static Vector logData = new Vector();

    public static void logToScreen(String str) {

        logData.add(str);
    

    }

    Now use it in your canvas.

    public static Vector getLogData() {

        return logData;
    

    }