In Eclipse, how can I write a debug statement to a console window? I tried:
System.out.print(urls);
System.out.println(urls);
Log.d("tag", urls);
But I don't see the values being displayed anywhere.
Thanks.
In Eclipse, how can I write a debug statement to a console window? I tried:
System.out.print(urls);
System.out.println(urls);
Log.d("tag", urls);
But I don't see the values being displayed anywhere.
Thanks.
Create a console and write to it. When a console is created, you give it a name. That way your console output can be kept separate from other plugin's console output. See this article for details.
http://wiki.eclipse.org/FAQ_How_do_I_write_to_the_console_from_a_plug-in%3F
Are you sure you have the console window in eclipse setup to display output? On the menu bar in eclipse, go to Window->Show View->Console. When you run the program, that console window should be where your System.out.print(ln) output is displayed.
If you are running some kind of client-server application, you may actually have multiple consoles. If you see a console, there should be a little arrow icon next to it. Use that to dropdown a list of all the various consoles, and pick the appropriate one.
If you are running any class having main method and want to print logs on eclipse console, then create a file "log4j.properties" in src/main/resources
If you want to print log in your test classes then put this file in src/test/resources.
log4j.properties
log4j.rootLogger=INFO, DEBUG, WARN, ERROR, stdout log4j.appender.stdout=org.apache.log4j.ConsoleAppender log4j.appender.stdout.layout=org.apache.log4j.PatternLayout log4j.appender.stdout.layout.ConversionPattern=%5p [%C:%L] [%t] - %m%n log4j.logger.backtype.storm=DEBUG log4j.logger.clojure.tools=DEBUG
There is a simple way to switch between client and server outputs in eclipse. Please see the screenshot which shows an option to toggle between the console outputs.
try this , it will output in console tab
System.out.print("Hello World ..... !");
// Redirect the stdout and stderr to the LogPanel
SystemLogger out = new SystemLogger(System.out, Level.INFO);
SystemLogger err = new SystemLogger(System.err, Level.ERROR);
System.setOut(out);
System.setErr(err);
I assume your code is in Java? If you want to use a logger that will print out to your console similarly to "system.out.println();", add java.util.logging to your eclipse project. import java.util.logging.Logger;
Then inside each class where you want output to your console, add private static final Logger LOG = Logger.getLogger(<your_class_name>.class.getName());
replacing with your class name.
And where you want console output, put a line in that part of your class like LOG.info("code got to this point!");
similarly to how you would use system.out.println();
I only use the logger instead of system.out.println();
statements because the logging seems more professional. And frankly the logger is less key strokes to write log.info than system.out.println, which saves time.
This article is where I learned the logging info: https://examples.javacodegeeks.com/core-java/util/logging/java-util-logging-example/