File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes how to stop printing log in console? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "how to stop printing log in console?" Watch "how to stop printing log in console?" New topic
Author

how to stop printing log in console?

sze sze chan
Greenhorn

Joined: Jul 27, 2011
Posts: 18
Hi everyone,

i'm currently doing a code enhancement on a java program by using eclipse

the previouse version has used logger, and i have no idea how to use log at all....

so I've commanded off the log lines,

however, when i run the program, the program prints many log messages
something like this:


log4j: reset attribute= "false".
log4j: Threshold ="null".
log4j: Retreiving an instance of org.apache.log4j.Logger.
log4j: Setting [gic.dpms] additivity to [true].
log4j: Class name: [org.apache.log4j.rolling.RollingFileAppender]
log4j: Setting property [immediateFlush] to [false].
log4j: Setting property [fileNamePattern] to [/opt/pgadev/log/pegasus.log.%d].
log4j: Parsing layout of class: "org.apache.log4j.PatternLayout"

I'm wondering is there anyway to stop printing the log4j message?
any help will be much appreciated, thanks
John Jai
Bartender

Joined: May 31, 2011
Posts: 1776
Check in log4j.properties whether stdout is configured
Wouter Oet
Saloon Keeper

Joined: Oct 25, 2008
Posts: 2700

Is it me or is that kind of wrong . You don't get how to logger works so you comment the logging statements, wouldn't learning how to logger works be a much better solution?


"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
sze sze chan
Greenhorn

Joined: Jul 27, 2011
Posts: 18

Wouter Oet wrote:Is it me or is that kind of wrong . You don't get how to logger works so you comment the logging statements, wouldn't learning how to logger works be a much better solution?


Hi,
I've tried to do research on logging and the properties set up thing kind of confuse me.
this program did not used the normal log4 jar or properties, the previous developer wrote a log4j.xml and log4j.dtd himself.
And sadly I can't figure out how does that two file function when I still very confuse with the basic logging thing. The previous developer didn't really give me much information...
And I did spent few days on that, it always tells me something like log4j properties is not configured. and I tried reinstall all plugins in a new package, it gives me this

The project deadline is just in few days and I still have many many other things to work on, those documentation, user guide, and the Linux thing.

It's all very very very new to me.So I've decided to spend my time on more urgent work.

And I'm not sure if the logging message will be printed when it runs on Unix? So I've tried to comment off the logging and hopefully it won't come out there .... I cant test it out because I still have the problem with class path setting on Unix.

Anyway, I will appreciate it if you could provide any suggestion based on this problem. thanks
Ove Lindström
Ranch Hand

Joined: Mar 10, 2008
Posts: 326

Well, to be honest but somewhat rude, you have a RTFM-problem. And the most that we could do here is to re-write the manual found at http://logging.apache.org/log4j/1.2/manual.html.

The description for the Log4J-XML configuration format is found at http://wiki.apache.org/logging-log4j/Log4jXmlFormat.

The log4j.properties or log4j.xml must be found at the root of a classpath entry. If you take a look at http://www.vaannila.com/log4j/log4j-xml-configuration.html you can see how to load a configuration file programmatically.

To point out the file from the java-command, you use the -D flag, as in -Dlog4j.configuration=log4j.xml.

If you are using Tomcat, you need to put that in the CATALINA_OPTS either as a system variable of in the startup script.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to stop printing log in console?