It's not a secret anymore!
The moose likes Java in General and the fly likes log4j console output Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "log4j console output" Watch "log4j console output" New topic

log4j console output

David Garratt
Ranch Hand

Joined: Aug 08, 2003
Posts: 208

When I run my application from within Eclipse my debug output appears in the eclipse 'console' window. If I want to see this output in the dos window that opens when I run my application do I need to change the xml log4j config file ? The syntax seems a little cryptic so say the least.

Many thanks in advance.

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">

<log4j:configuration xmlns:log4j=''>

<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
<param name="Threshold" value="DEBUG"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%-5p [%t] %c - %m%n"/>

<level value="debug" />
<appender-ref ref="CONSOLE" />
Joe Ess

Joined: Oct 29, 2001
Posts: 9150

Originally posted by David Garratt:
The syntax seems a little cryptic so say the least.

If that's the most cryptic thing you ever run across, you're a VERY lucky indivudual!
I don't think you'll have to change your configuration, but you will have to tell log4j to use that configuration with a command-line parameter like this:

[How To Ask Questions On JavaRanch]
David Garratt
Ranch Hand

Joined: Aug 08, 2003
Posts: 208

I run my app via a batch file (DOS) with a command line starting

%JAVA_HOME%\bin\javaw.exe -D.\xml\log4j.xml -classpath .\bin;........

I have a utility class which has a number of methods within it one of which is this :-

public static void initLogging()

This is called a the start of my application.

Any debug messages are generated as example :-

public static void test()
final Logger logger = Logger.getLogger(MyTest.class);

logger.debug("something meaningful");


These messages appear in the Eclipse "console" window when I run from the IDE, but I was rather expecting to see them in the DOS window when the app is run from the desktop direct. I have "ECHO ON" at the start of my batch file.

Should I be doing some more coding in my initLogging routine.

Thanks in advance

I agree. Here's the link:
subject: log4j console output
It's not a secret anymore!