I tried with different ways to print value on Log File of Netbenas6.9.1 . I am using Tomcat6.0 . Also checked server log ..but values r not getting printed on any log.
Can any1 te开发者_StackOverflowll me how to print values using System.out.println() / java.util.Logger on console?
Have you considered that the code may not be actually getting executed? That might be why no log message appears.
Since you ask you can print the results of the toString()
method of any object to the console like this:
System.out.println( objectToBePrinted );
You can also append to a file simply like this:
try {
PrintWriter logWriter = new PrintWriter(new FileWriter( myLogFile, true ), true );
logWriter.println( objectToBePrinted );
logWriter.close();
} catch ( IOException ioe ) { ioe.printStackTrace(); }
Before going down this route though it is worth considering using a debugger to investigate both why the logger is not logging and whatever issue you are trying to resolve through this logging. Debuggers give you access to a lot more information than a logger can.
精彩评论