How to use the java Logger object?

Hey everyone, this is a re-post of something I wrote in another thread but a more summarized version. Perhaps it could help me solve quite a big problem.



I found out about the logger:

https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:advanced:read_graphic_card_capabilites

but I have no idea how to “print” the data from the logging. So I used a simple “println” method using this code, at the end of the simpleInitApp() method:



Collection caps = renderer.getCaps();

System.out.println(caps.toString());


(as well as importing “com.jme3.renderer.Caps” and “java.util.Collection”).



I only got this printout: [NonPowerOfTwoTextures], which I don’t know what to make of (do I have a non power of two textures capability? or do I not? and where is all the other data that could be printed about my card?)



So how do I actually get the entire log as a string?



Thank you,

Amir,

It seems like you didn’t read the entire link you gave, all your questions can be answred there. About the NonPowerOfTwoTextures stuff, yeah, your graphic card does support that, that’s because it was printed out.

Oh, I’m sorry I didn’t include a part of my code. My bad.

I had this line:

Logger.getLogger(HelloNode.class.getName()).log(Level.INFO, “Caps: {0}”, caps.toString());

(The line was placed of course in the “HelloNode” class).



The link I gave does not specify how to print or store as a String the information logged by the logger.

Unless I misunderstood something fundamental over there.

It says I can print using the Caps, which I did; however I only got one feature - the NonPowerOfTwoTextures. The information should include a lot more than that as far as I’ve seen (the link shows multiple log entries, many graphic card capabilities, etc.), which might relate to the logger “flags” etc. I have tried looking it up online but I really didn’t get how I could simply take the information I logged with the line (Logger.getLogger…).

I’m having multiple problems with my graphics card and this seems to be the only way to identify them correctly.

For example, I can’t load files to a Normal Map and it drives me crazy :slight_smile:



Amir.

Plz, show us the entire output log you have when you execute that line.

Yes! that’s exactly my question!

It is really a starter’s question, but I want to know where can I actually find the log!

I run the program and nothing is printed to console or created anywhere. How do I access the output log?

Omg, it’s very strange. It should print something. What’s the code you are running?

here, the simplest code there is :slight_smile:



[java]

package jme3test.helloworld;



import java.util.Collection;

import java.util.logging.Level;

import java.util.logging.Logger;



import com.jme3.app.SimpleApplication;

import com.jme3.renderer.Caps;



public class HelloNode extends SimpleApplication

{

public static void main(String[] args){



HelloNode app = new HelloNode();

app.start();

}



public void simpleInitApp()

{

Collection<Caps> caps = renderer.getCaps();

Logger.getLogger(HelloNode.class.getName()).log(Level.INFO, “Caps: {0}”, caps.toString());

}



}

[/java]



and here’s the printout to console (standard I think):





Dec 09, 2012 10:36:33 PM com.jme3.system.JmeDesktopSystem initialize

INFO: Running on jMonkeyEngine 3.0.0 RC2

Dec 09, 2012 10:36:33 PM com.jme3.system.Natives extractNativeLibs

INFO: Extraction Directory: C:UsersAmir KrauseworkspaceHelloJME3

Dec 09, 2012 10:36:33 PM com.jme3.system.lwjgl.LwjglAbstractDisplay run

INFO: Using LWJGL 2.8.4

Dec 09, 2012 10:36:33 PM com.jme3.system.lwjgl.LwjglDisplay createContext

INFO: Selected display mode: 1024 x 768 x 0 @0Hz

Dec 09, 2012 10:36:34 PM com.jme3.system.lwjgl.LwjglContext printContextInitInfo

INFO: Adapter: null

Dec 09, 2012 10:36:34 PM com.jme3.system.lwjgl.LwjglContext printContextInitInfo

INFO: Driver Version: null

Dec 09, 2012 10:36:34 PM com.jme3.system.lwjgl.LwjglContext printContextInitInfo

INFO: Vendor: ATI Technologies Inc.

Dec 09, 2012 10:36:34 PM com.jme3.system.lwjgl.LwjglContext printContextInitInfo

INFO: OpenGL Version: 4.2.11931 Compatibility Profile Context

Dec 09, 2012 10:36:34 PM com.jme3.system.lwjgl.LwjglContext printContextInitInfo

INFO: Renderer: ATI Mobility Radeon HD 5400 Series

Dec 09, 2012 10:36:34 PM com.jme3.system.lwjgl.LwjglContext printContextInitInfo

INFO: GLSL Ver: 4.20

Dec 09, 2012 10:36:34 PM com.jme3.system.lwjgl.LwjglTimer

INFO: Timer resolution: 1,000 ticks per second

Dec 09, 2012 10:36:34 PM com.jme3.asset.DesktopAssetManager

INFO: DesktopAssetManager created.

Dec 09, 2012 10:36:34 PM com.jme3.renderer.Camera

INFO: Camera created (W: 1,024, H: 768)

Dec 09, 2012 10:36:34 PM com.jme3.renderer.Camera

INFO: Camera created (W: 1,024, H: 768)

Dec 09, 2012 10:36:34 PM com.jme3.input.lwjgl.LwjglMouseInput initialize

INFO: Mouse created.

Dec 09, 2012 10:36:34 PM com.jme3.input.lwjgl.LwjglKeyInput initialize

INFO: Keyboard created.

Dec 09, 2012 10:36:35 PM com.jme3.audio.lwjgl.LwjglAudioRenderer initInThread

INFO: AudioRenderer supports 64 channels

Dec 09, 2012 10:36:35 PM com.jme3.audio.lwjgl.LwjglAudioRenderer initInThread

INFO: Audio effect extension version: 1.0

Dec 09, 2012 10:36:35 PM com.jme3.audio.lwjgl.LwjglAudioRenderer initInThread

INFO: Audio max auxilary sends: 4

Dec 09, 2012 10:36:35 PM com.jme3.material.MaterialDef

INFO: Loaded material definition: Unshaded

Dec 09, 2012 10:36:35 PM com.jme3.scene.Node attachChild

INFO: Child (BitmapFont) attached to this node (null)

Dec 09, 2012 10:36:35 PM jme3test.helloworld.HelloNode simpleInitApp

INFO: Caps: [NonPowerOfTwoTextures]

Dec 09, 2012 10:36:35 PM com.jme3.scene.Node attachChild

INFO: Child (null) attached to this node (Gui Node)

Dec 09, 2012 10:36:35 PM com.jme3.scene.Node attachChild

INFO: Child (BitmapFont) attached to this node (null)

Dec 09, 2012 10:36:35 PM com.jme3.scene.Node attachChild

INFO: Child (null) attached to this node (Statistics View)

Dec 09, 2012 10:36:35 PM com.jme3.scene.Node attachChild

INFO: Child (BitmapFont) attached to this node (null)

Dec 09, 2012 10:36:35 PM com.jme3.scene.Node attachChild

INFO: Child (null) attached to this node (Statistics View)

Dec 09, 2012 10:36:35 PM com.jme3.scene.Node attachChild

INFO: Child (BitmapFont) attached to this node (null)

Dec 09, 2012 10:36:35 PM com.jme3.scene.Node attachChild

INFO: Child (null) attached to this node (Statistics View)

Dec 09, 2012 10:36:35 PM com.jme3.scene.Node attachChild

INFO: Child (BitmapFont) attached to this node (null)

Dec 09, 2012 10:36:35 PM com.jme3.scene.Node attachChild

INFO: Child (null) attached to this node (Statistics View)

Dec 09, 2012 10:36:35 PM com.jme3.scene.Node attachChild

INFO: Child (BitmapFont) attached to this node (null)

Dec 09, 2012 10:36:35 PM com.jme3.scene.Node attachChild

INFO: Child (null) attached to this node (Statistics View)

Dec 09, 2012 10:36:35 PM com.jme3.scene.Node attachChild

INFO: Child (BitmapFont) attached to this node (null)

Dec 09, 2012 10:36:35 PM com.jme3.scene.Node attachChild

INFO: Child (null) attached to this node (Statistics View)

Dec 09, 2012 10:36:35 PM com.jme3.scene.Node attachChild

INFO: Child (BitmapFont) attached to this node (null)

Dec 09, 2012 10:36:35 PM com.jme3.scene.Node attachChild

INFO: Child (null) attached to this node (Statistics View)

Dec 09, 2012 10:36:35 PM com.jme3.scene.Node attachChild

INFO: Child (BitmapFont) attached to this node (null)

Dec 09, 2012 10:36:35 PM com.jme3.scene.Node attachChild

INFO: Child (null) attached to this node (Statistics View)

Dec 09, 2012 10:36:35 PM com.jme3.scene.Node attachChild

INFO: Child (BitmapFont) attached to this node (null)

Dec 09, 2012 10:36:35 PM com.jme3.scene.Node attachChild

INFO: Child (null) attached to this node (Statistics View)

Dec 09, 2012 10:36:35 PM com.jme3.scene.Node attachChild

INFO: Child (BitmapFont) attached to this node (null)

Dec 09, 2012 10:36:35 PM com.jme3.scene.Node attachChild

INFO: Child (null) attached to this node (Statistics View)

Dec 09, 2012 10:36:35 PM com.jme3.scene.Node attachChild

INFO: Child (BitmapFont) attached to this node (null)

Dec 09, 2012 10:36:35 PM com.jme3.scene.Node attachChild

INFO: Child (null) attached to this node (Statistics View)

Dec 09, 2012 10:36:35 PM com.jme3.scene.Node attachChild

INFO: Child (BitmapFont) attached to this node (null)

Dec 09, 2012 10:36:35 PM com.jme3.scene.Node attachChild

INFO: Child (null) attached to this node (Statistics View)

Dec 09, 2012 10:36:35 PM com.jme3.scene.Node attachChild

INFO: Child (BitmapFont) attached to this node (null)

Dec 09, 2012 10:36:35 PM com.jme3.scene.Node attachChild

INFO: Child (null) attached to this node (Statistics View)

Dec 09, 2012 10:36:35 PM com.jme3.scene.Node attachChild

INFO: Child (Statistics View) attached to this node (Gui Node)

Dec 09, 2012 10:36:35 PM com.jme3.scene.Node attachChild

INFO: Child (StatsDarken) attached to this node (Gui Node)

Dec 09, 2012 10:36:35 PM com.jme3.scene.Node attachChild

INFO: Child (StatsDarken) attached to this node (Gui Node)

Dec 09, 2012 10:36:35 PM com.jme3.renderer.lwjgl.LwjglGL1Renderer cleanup

INFO: Deleting objects and invalidating state

Dec 09, 2012 10:36:35 PM com.jme3.scene.Node detachChildAt

INFO: Gui Node (Node): Child removed.

Dec 09, 2012 10:36:35 PM com.jme3.scene.Node detachChildAt

INFO: Gui Node (Node): Child removed.

Dec 09, 2012 10:36:35 PM com.jme3.scene.Node detachChildAt

INFO: Gui Node (Node): Child removed.

Dec 09, 2012 10:36:35 PM com.jme3.scene.Node detachChildAt

INFO: Gui Node (Node): Child removed.

Dec 09, 2012 10:36:35 PM com.jme3.input.lwjgl.LwjglMouseInput destroy

INFO: Mouse destroyed.

Dec 09, 2012 10:36:35 PM com.jme3.input.lwjgl.LwjglKeyInput destroy

INFO: Keyboard destroyed.

Dec 09, 2012 10:36:35 PM com.jme3.system.lwjgl.LwjglAbstractDisplay deinitInThread

INFO: Display destroyed.

I don’t know what’s going on really. Make sure you have updated your graphic card driver.

It is fully updated (October 2012).

The “Caps” do contain at least one thing - the NonPowerOfTwo… thingy. Are you saying that by simply invoking the Logger.getLogger… I should get a log printout to the console?

I just want my log :slight_smile:

@amirkr said:
I found out about the logger:
https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:advanced:read_graphic_card_capabilites
but I have no idea how to “print” the data from the logging. So I used a simple “println” method using this code, at the end of the simpleInitApp() method:

Collection caps = renderer.getCaps();
System.out.println(caps.toString());

(as well as importing “com.jme3.renderer.Caps” and “java.util.Collection”).

I only got this printout: [NonPowerOfTwoTextures], which I don’t know what to make of (do I have a non power of two textures capability? or do I not? and where is all the other data that could be printed about my card?)

So how do I actually get the entire log as a string?

Thank you,
Amir,


This is a fundamental java language question. It returns a collection. A collection is not a String. You must iterate over the members of the collection and print them one by one.
http://docs.oracle.com/javase/tutorial/collections/intro/index.html
@jmaasing said:
This is a fundamental java language question. It returns a collection. A collection is not a String. You must iterate over the members of the collection and print them one by one.
http://docs.oracle.com/javase/tutorial/collections/intro/index.html


Oh no :) I know how to program on that level (just not with jMonkey ;) ).
This collection has a size of 1 (I checked) meaning it only has a single value stored.
In any event, I also iterated over it using the code:
[java]
Collection<Caps> caps = renderer.getCaps();
Iterator<Caps> it = caps.iterator();
while(it.hasNext())
System.out.println(it.next());

[/java]

It still returned only one result (the NonPowerOfTwo...).
Obviously you could not have known I tried it since I forgot to mention it, I'm sorry. The question is still how to get the "log" which was recorded by the "Logger" object. This might too be a fundamental Java question, just a different one ;)

Amir.

Java’s Logger and trying to somehow intercept things from it is kind of beyond the discussion of JME. I’m still not sure why you want to do it anyway. They’re just string values and not like you can easily interpret them in code.



Something does seem pretty screwed up with your drivers, though. The fact that it only has one Cap is bad… and really odd. ATI drivers never cease to amaze me with their screwed-upped-ness.

@amirkr said:
Oh no :) I know how to program on that level (just not with jMonkey ;) ).
It still returned only one result (the NonPowerOfTwo...).
Obviously you could not have known I tried it since I forgot to mention it, I'm sorry. The question is still how to get the "log" which was recorded by the "Logger" object. This might too be a fundamental Java question, just a different one ;)

Amir.

Oh, sorry then :) But as pspeed says, you don't actually want the log-record. It says nothing more than what you put into it. It is no more magical than println in the information it contains. Can't help you with the driver, I use nVidia on linux :)

OK guys, thanks a lot to you all for your answers! :slight_smile:

Seems the next stage is test this code on other machines and see what happens, then if it is really the driver, try to handle that issue.

I will stop posting on this thread since as you said, that is everything I can do and the question is beyond the scope of jMonkey now.



Amir.