The Log class:

API for sending log output.

Generally, use the Log.v() Log.d() Log.i() Log.w() and Log.e() methods.

The order in terms of verbosity, from least to most is ERROR, WARN, INFO, DEBUG, VERBOSE. Verbose should never be compiled into an application except during development. Debug logs are compiled in but stripped at runtime. Error, warning and info logs are always kept.

Outside of Android, System.out.println(String msg) is used.

Answer from nhaarman on Stack Overflow
Top answer
1 of 4
141

The Log class:

API for sending log output.

Generally, use the Log.v() Log.d() Log.i() Log.w() and Log.e() methods.

The order in terms of verbosity, from least to most is ERROR, WARN, INFO, DEBUG, VERBOSE. Verbose should never be compiled into an application except during development. Debug logs are compiled in but stripped at runtime. Error, warning and info logs are always kept.

Outside of Android, System.out.println(String msg) is used.

2 of 4
25

Use the Android logging utility.

http://developer.android.com/reference/android/util/Log.html

Log has a bunch of static methods for accessing the different log levels. The common thread is that they always accept at least a tag and a log message.

Tags are a way of filtering output in your log messages. You can use them to wade through the thousands of log messages you'll see and find the ones you're specifically looking for.

You use the Log functions in Android by accessing the Log.x objects (where the x method is the log level). For example:

CopyLog.d("MyTagGoesHere", "This is my log message at the debug level here");
Log.e("MyTagGoesHere", "This is my log message at the error level here");

I usually make it a point to make the tag my class name so I know where the log message was generated too. Saves a lot of time later on in the game.

You can see your log messages using the logcat tool for android:

Copyadb logcat

Or by opening the eclipse Logcat view by going to the menu bar

CopyWindow->Show View->Other then select the Android menu and the LogCat view
🌐
Oracle
docs.oracle.com › javase › 8 › docs › technotes › guides › deploy › console_trace_log.html
22 Java Console, Tracing, and Logging
April 21, 2026 - Tracing is a facility to redirect any output in the Java Console to a trace file. Similar to tracing, logging is a facility to redirect any output in the Java Console to a log file using the Java Logging API.
Discussions

Log console output to a log file Java logger - Stack Overflow
I am trying to write all my console output to a log file using the Java Logger class. More on stackoverflow.com
🌐 stackoverflow.com
debugging - Console.log in a Java Back-end - Stack Overflow
I'm using Java with Spring Boot in IntelliJ Community edition. I usually use console.log() in the front-end to debug my code and see the value of a variable. Here in the back-end I try to do the ... More on stackoverflow.com
🌐 stackoverflow.com
Capturing console output and displaying it in Java applet.
https://docs.oracle.com/javase/7/docs/api/java/lang/System.html#setOut(java.io.PrintStream) Capture the output and either duplicate it or simply store it and display it on the GUI. Duplicating makes sense so you can still send to stdout in the event of a failure. More on reddit.com
🌐 r/javahelp
6
2
May 23, 2017
[Guide] Controlling console and log output with log4j

Good writeup. I'll also add that wiki.vg has an article about debug logging (which is similar to this, but focuses on vanilla's log messages, and is also useful clientside).

Also, you can write custom log4j plugins (I did so once here); here's an example which restarts the server when a certain message appears in the log. It's not the best use, but the same concept could apply - you could, for instance, send yourself an email when something happens.

More on reddit.com
🌐 r/admincraft
6
22
May 4, 2017
🌐
Delft Stack
delftstack.com › home › howto › java › console log in java
console.log in Java | Delft Stack
March 4, 2025 - The most straightforward way to log messages in Java is by using the System.out.println method. This method prints text to the console, making it easy to track the flow of your program and display variable values at different stages.
🌐
Rollbar
rollbar.com › home › where are java errors logged?
Where are Java Errors Logged? | Rollbar
June 11, 2021 - The configuration file is where the layouts and appenders are declared. Look for a text file named logback.xml. It should be located somewhere in the project classpath. In this example, you can see it's set to log to standard output on the console:
🌐
Java Code Geeks
javacodegeeks.com › home › core java
Testing Logging Output in Java - Java Code Geeks
January 19, 2021 - In due course, I’m planning to ... the output appears on the console AND is also tapped. See this proposed README for more. Yes and no. It’s enormously convenient and easy to do. So, I’m inclined to default to it. However, for fine-grained testing of exactly what is being sent to the logging library, the reading of strings from a console is a bit messy. Do you want to know how to develop your skillset to become a Java ...
🌐
SigNoz
signoz.io › guides › java logging: from println to production-ready logs
Java Logging: Setup, Log4j2, SLF4J & Monitoring | SigNoz
July 10, 2024 - Development teams need verbose output on the console, while production teams need structured files that rotate predictably. Maintain two configuration files—log4j2-dev.xml for local debugging and log4j2-prod.xml for production and pick the right one at startup: # Local run with colored console logs java -Dlog4j.configurationFile=log4j2-dev.xml -jar app.jar # Production run with JSON + rolling files java -Dlog4j.configurationFile=log4j2-prod.xml -jar app.jar
🌐
Coderanch
coderanch.com › t › 485476 › java › Saving-Java-Console-output-file
Saving Java Console output to file (Java in General forum at Coderanch)
A way to make the console persist ... extensive Swing experience ... The log file is saved as "plugin#####.log" in C:\Documents and Settings\[your login]\Application Data\Sun\Java\Deployment\log....
Find elsewhere
🌐
Loggly
loggly.com › home › java logging basics
Java Logging Basics - The Ultimate Guide To Logging - Loggly
June 27, 2025 - Log4j supports multiple different configuration file formats, including XML, JSON, and YAML. When your Java application starts, Log4j searches for a log4j2.<format> file in the project directory. If it doesn't find one, it will default to console output.
🌐
Sentry
blog.sentry.io › a-guide-to-logging-and-debugging-in-java
Logging & Debugging in Java - Guide | Sentry Blog
September 25, 2025 - This built-in framework allows you to easily record and output different events in your application, such as informational messages, warnings, or errors. Using java.util.logging, you can specify log levels to indicate the importance of each message:
🌐
LabEx
labex.io › tutorials › java-how-to-print-output-to-console-in-java-417652
How to print output to console in Java | LabEx
The console, also known as the command line or terminal, serves as a text-based interface for interacting with the computer and executing commands. In Java, the primary method for printing output to the console is through the System.out.println() method.
🌐
Codecademy
codecademy.com › docs › java › output › .println()
Java | Output | .println() | Codecademy
November 5, 2022 - Prints its argument to the console followed by a new line.
🌐
Stack Overflow
stackoverflow.com › questions › 39810204 › log-console-output-to-a-log-file-java-logger › 39819741
Log console output to a log file Java logger - Stack Overflow
* @param args * @throws IOException */ /* -- START MAIN -- */ public static void main(String[] args) throws IOException { Settings.settingsRead(); try { // This block configure the logger with handler and formatter fh = new FileHandler("logs/hudedit_log_" + dateFormat.format(cal.getTime()) + ".log"); logger.setLevel(Level.ALL); handler.setFormatter(new SimpleFormatter()); logger.addHandler(handler); logger.info("hello world"); logger.addHandler(fh); SimpleFormatter formatter = new SimpleFormatter(); fh.setFormatter(formatter); logger.info("Test"); } catch (SecurityException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } How do I make it so that it takes everything that has been outputted to the console and write it to a file efficiently rather than putting logger.info("Whatever the thing I want to output"); everywhere?
🌐
DZone
dzone.com › testing, deployment, and maintenance › testing, tools, and frameworks › unit testing console output made easy
Unit Testing Console Output Made Easy
July 16, 2021 - ConsoleCaptor is able to capture anything which is printed on the console even logs from logging API such as SLF4J, Log4J2, Log4J, Java Util Logging. It will return just the raw text including the log level, timestamp, etc.
🌐
Perforce Support
portal.perforce.com › s › article › Export-IDE-console-log-to-external-file
Export IDE console log to external file - Perforce Support
January 24, 2024 - import java.io.FileOutputStream; import java.io.PrintStream; System.setOut(new PrintStream(new FileOutputStream("output.txt"))); System.out.println("This is test output"); Then, all console output generated by System.out.* will be redirected to the output file.
🌐
DigitalOcean
digitalocean.com › community › tutorials › logger-in-java-logging-example
Java Logger: Logging Examples with Log4j & SLF4J | DigitalOcean
August 3, 2022 - handlers= java.util.logging.ConsoleHandler .level= FINE # default file output is in user's home directory.
🌐
IBM
ibm.com › support › pages › enable-java-console-logging
Enable Java Console logging
How can the console logging be turned on to trace the TADDM GUI processing?
🌐
Hitachi
itpfdoc.hitachi.co.jp › manuals › 3021 › 3021336100e › H3610046.HTM
3.5.2 Collecting a Java console log : Job Management Partner 1/Data Highway - Server User's Guide
If you cannot solve the problem, collect log data by following the procedure below and then send the log file to the system administrator. ... From the Start menu, click Control Panel. The Control Panel appears. Double-click the Java icon. The Java Control Panel appears. Click the Advanced tab, and then select all the check boxes under Debugging. Click the OK button. Restart Internet Explorer (IE). Do the same operation as when the problem occurred. In the task tray, right-click the displayed Java icon. Click Open version Console.
🌐
Jalview
jalview.org › help › html › logging.html
The Java Console, Logging and Reporting Bugs
Jalview Executable Jar Launch Logs ... set memory and linux dpi settings before re-launching jalview.bin.Jalview), will output logging information to STDOUT and STDERR. ... The Java Console is opened by selecting Tools → Show Java Console....