Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Developer
Posts: 1,474
Registered: ‎04-14-2009
My Device: Not Specified

Re: Help! Logging won't work on Bold 9000 on startup

Hm. I didn't know that the Debugger can't be attached while the device is powering up. Interesting...
Please use plain text.
Developer
peter_strange
Posts: 19,599
Registered: ‎07-14-2008
My Device: Not Specified

Re: Help! Logging won't work on Bold 9000 on startup

It can be, but the BB end doesn't seem to catch the hook up till after most of the start-up processing has been done.
Please use plain text.
Developer
justindutoit
Posts: 400
Registered: ‎05-31-2009
My Device: Not Specified

Re: Help! Logging won't work on Bold 9000 on startup

Yes gents, this is what I've found. So what do I do? Can you definitely write to the BlackBerry Bold event log in main() while the phone is starting up? Mr Sohm, is there any way to attach to the Bold device while it is starting?

 

Cheers,

J

Please use plain text.
Developer
martijnbrinkers
Posts: 155
Registered: ‎02-18-2009
My Device: Not Specified

Re: Help! Logging won't work on Bold 9000 on startup

My app logs at startup without any problems.

 

Are you sure that the event logger does not filter out your logs (see event log options). Perhaps you have multiple loggers defined...

Please use plain text.
Developer
Posts: 1,474
Registered: ‎04-14-2009
My Device: Not Specified

Re: Help! Logging won't work on Bold 9000 on startup

Interestingly enough, I have a Bold v4.6.0.x, and logging does not work on startup there. The very same code running on some newer handheld software and devices seems to work just fine. Looks like it's a handheld software version dependent issue.

Please use plain text.
Developer
justindutoit
Posts: 400
Registered: ‎05-31-2009
My Device: Not Specified

Re: Help! Logging won't work on Bold 9000 on startup

Hi- would you mind posting your code in main() which does the logging? Yes I'm sure the messages aren't being filtered out. What do you mean by multiple loggers?
Please use plain text.
Developer
martijnbrinkers
Posts: 155
Registered: ‎02-18-2009
My Device: Not Specified

Re: Help! Logging won't work on Bold 9000 on startup

I have created a logger similar to Log4J. I only use EventLogger.logEvent inside the logger classes. I however do nothing special. The only difference I see is that I initialize the EventLogger with a static initializer.

 

class SomeClass {

 

    static {
        EventLogger.register(LoggerImpl.LOGGER_GUID, GLOBAL_LOGGER_NAME, EventLogger.VIEWER_STRING);
    }

...

}

 

could you try to initialize with a static initializer?

Please use plain text.
Developer
justindutoit
Posts: 400
Registered: ‎05-31-2009
My Device: Not Specified

Re: Help! Logging won't work on Bold 9000 on startup

[ Edited ]

Hi- is this working on a Bold 4.6? and, do I need to create a class or can I just do it in main(), and if so, how please? Pl keep in mind I am new to java. My current code is (pl say how to modify it):

 

    public static void main(String[] args)
    {
                EventLogger.register(0x4c9d3452d87922f2L, "MonthlySpend", EventLogger.VIEWER_STRING);
               
                String logMessage = "main... ";
                if (args != null && args.length > 0)
                    logMessage += args[0];
                    
                if (EventLogger.logEvent(0x4c9d3452d87922f2L, logMessage.getBytes(), EventLogger.ALWAYS_LOG)) {
                    System.out.println("Log Successful!");
                }

Please use plain text.
Developer
martijnbrinkers
Posts: 155
Registered: ‎02-18-2009
My Device: Not Specified

Re: Help! Logging won't work on Bold 9000 on startup

Just place the static initializer somewhere in the 'body' of your main class and remove EventLogger.register from your main:

 

class YourMainClass

{

    static {
        EventLogger.register(0x4c9d3452d87922f2L, "MonthlySpend", EventLogger.VIEWER_STRING);
    }

 

public static void main(String[] args)
 {
                String logMessage = "main... ";
                if (args != null && args.length > 0)
                    logMessage += args[0];
                    
                if (EventLogger.logEvent(0x4c9d3452d87922f2L, logMessage.getBytes(), EventLogger.ALWAYS_LOG)) {
                    System.out.println("Log Successful!");
                }

}

...

}

Please use plain text.
Developer
justindutoit
Posts: 400
Registered: ‎05-31-2009
My Device: Not Specified

Re: Help! Logging won't work on Bold 9000 on startup

Martijn- does your logging work on the Bold 4.6? I am testing on a Bold 4.6- what BlackBerry are you testing on?

Please use plain text.