• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

log4j console output

 
Ranch Hand
Posts: 333
1
Mac Eclipse IDE Safari
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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='http://jakarta.apache.org/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"/>
</layout>
</appender>

<root>
<level value="debug" />
<appender-ref ref="CONSOLE" />
</root>
</log4j:configuration>
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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:

 
David Garratt
Ranch Hand
Posts: 333
1
Mac Eclipse IDE Safari
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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()
{
DOMConfigurator.configure("xml/log4j.xml");
}

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

Dave
 
No thanks. We have all the government we need. This tiny ad would like you to leave now:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic