So I’ve been looking into logging for the last two days and still I can’t get a straight answer. Using the wiki code , I am able to turn off logging
for everything except when children are attached to the BatchNode. I believe the code is slowing down my loading dramatically
I usethe following for logging:
[java]
java.util.logging.Logger.getLogger(nameOfMyClass.class.getName()).setLevel(Level.OFF);
[/java]
I even tried putting this logger code in every class I had - no luck
heres the output
[java]
INFO: batch (BatchNode): Child removed.
Mar 22, 2012 9:04:07 PM com.jme3.scene.Node detachChildAt
INFO: batch (BatchNode): Child removed.
Mar 22, 2012 9:04:07 PM com.jme3.scene.Node detachChildAt
INFO: batch (BatchNode): Child removed.
Mar 22, 2012 9:04:07 PM com.jme3.scene.Node detachChildAt
INFO: batch (BatchNode): Child removed.
Mar 22, 2012 9:04:07 PM com.jme3.scene.Node detachChildAt
INFO: batch (BatchNode): Child removed.
Mar 22, 2012 9:04:07 PM com.jme3.scene.Node detachChildAt
INFO: batch (BatchNode): Child removed.
Mar 22, 2012 9:04:07 PM com.jme3.scene.Node detachChildAt
INFO: batch (BatchNode): Child removed.
Mar 22, 2012 9:04:07 PM com.jme3.scene.Node detachChildAt
INFO: batch (BatchNode): Child removed.
Mar 22, 2012 9:04:07 PM com.jme3.scene.Node detachChildAt
INFO: batch (BatchNode): Child removed.
Mar 22, 2012 9:04:07 PM com.jme3.scene.Node detachChildAt
INFO: batch (BatchNode): Child removed.
Mar 22, 2012 9:04:07 PM com.jme3.scene.Node detachChildAt
INFO: batch (BatchNode): Child removed.
Mar 22, 2012 9:04:07 PM com.jme3.scene.Node detachChildAt
INFO: batch (BatchNode): Child removed.
Mar 22, 2012 9:04:07 PM com.jme3.scene.Node detachChildAt
INFO: batch (BatchNode): Child removed.
Mar 22, 2012 9:04:07 PM com.jme3.scene.Node detachChildAt
INFO: batch (BatchNode): Child removed.
Mar 22, 2012 9:04:07 PM com.jme3.scene.Node detachChildAt
INFO: batch (BatchNode): Child removed.
Mar 22, 2012 9:04:07 PM com.jme3.scene.Node detachChildAt
INFO: batch (BatchNode): Child removed.
Mar 22, 2012 9:04:07 PM com.jme3.scene.Node detachChildAt
INFO: batch (BatchNode): Child removed.
Mar 22, 2012 9:04:07 PM com.jme3.scene.Node detachChildAt
INFO: batch (BatchNode): Child removed.
Mar 22, 2012 9:04:07 PM com.jme3.scene.Node detachChildAt
INFO: batch (BatchNode): Child removed.
Mar 22, 2012 9:04:07 PM com.jme3.scene.Node detachChildAt
INFO: batch (BatchNode): Child removed.
Mar 22, 2012 9:04:07 PM com.jme3.scene.Node detachChildAt
INFO: batch (BatchNode): Child removed.
Mar 22, 2012 9:04:07 PM com.jme3.scene.Node detachChildAt
INFO: batch (BatchNode): Child removed.
Mar 22, 2012 9:04:07 PM com.jme3.scene.Node detachChildAt
INFO: batch (BatchNode): Child removed.
Mar 22, 2012 9:04:07 PM com.jme3.scene.Node detachChildAt
INFO: batch (BatchNode): Child removed.
Mar 22, 2012 9:04:07 PM com.jme3.scene.Node detachChildAt
INFO: bat etcccccccccccccccccccccccccccccccc
[/java]
Dont forget that the logger is created with a “weak key” when you use getLogger().
It means that the garbage collector can delete your logger and its parameters before you get inside your class.
To prevent loggers from being garbage collected, store them into a static variable or list.
For exemple :
[java] private static final List<java.util.logging.Logger> loggersHardLink = new ArrayList<java.util.logging.Logger>();
private static java.util.logging.Logger getLoggerAndMakeHardLink( String name )
{
java.util.logging.Logger logger = java.util.logging.Logger.getLogger( name );
loggersHardLink.add( logger );
return logger;
}
[/java]
then
[java] getLoggerAndMakeHardLink( “com.jme3” ).setLevel( Level.WARNING );
[/java]
I tried your code and still no luck :(((
I dont think its being garbage collected as I less logs in the app… however I still see that attach/detach ugly logging which is slowing me a lot…
Which version of jMonkey are you using ? Can you show us your code ?
If you want to turn off logging only while the batching happens, right before you invoke it turn logging off completely, then turn it back on right after.
[java]
Logger.getLogger("").setLevel(Level.OFF);
// do your batching here
Logger.getLogger("").setLevel(Level.WARNING);
[/java]
FYI, my logger’s “setting” is the first line in main(…) and it works as it should.
I was calling it after the batching – how stupid lol srry & thx guys
That kind of stuff happens. But, really, after two days of searching you just noticed this?
The solution is often the simpler one… As far as simple, that’s hard to beat.
I know I’m embarrassed :S
If you don’t litter your code with printlns or run it through a debugger at some point… then you really haven’t “debugged” yet.
Assumption number 1 is usually “is this code even called?”. A println in there or stepping through in a debugger would have shown right away what the problem was. Just saying in case it matters next time.
@pspeed said:
If you don't litter your code with printlns or run it through a debugger at some point... then you really haven't "debugged" yet.
Assumption number 1 is usually "is this code even called?". A println in there or stepping through in a debugger would have shown right away what the problem was. Just saying in case it matters next time.
Can't agree more. The debugger is your friend!
I once spent 2 hours looking for a semicolon. (Before the days of syntax aware editors).
Actually I didn’t know I was looking for a semicolon, I was getting a really wierd syntax error report but in the end it turned out I was missing a semicolon. Only found it when I asked someone else to look at the code and they spotted it in 30 seconds.
I once spent 2 hours looking for a semicolon.
Ahahahah. C and C++ :D
Also, the debugger is your friend, but it should be a second choice.
Test cases rules (jUnit). ;)
@ozonegrif said:
Ahahahah. C and C++ :D
Also, the debugger is your friend, but it should be a second choice.
Test cases rules (jUnit). ;)
Lpc actually. A c variant used for developing text based muds.
@homsi said:
Damn @zarch how old are you ;) ?
Older than you probably... : p
I did start programming when I was 8 though which helps get a head start...
Lucky you… I started “real” programming or at least read my first java book 2 years ago and I’m all over the place here.