You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by Chris Gerrard <cg...@sct.com> on 2001/12/05 21:17:01 UTC

log4j:WARN File option not set for appender [STDOUT]. - help required

I get these following two messages when log4j starts up:

" log4j:WARN File option not set for appender [STDOUT].              "
" log4j:WARN Are you using FileAppender instead of ConsoleAppender?  "

and can find no reason for them, nor a way to suppress them.
Everything seems to work fine in that the logging occurs as I expect,
and I have a moderately rich set of classes with varying Categories
and Priorities (at least I think so.)

My properties file and initializing servlet are below.

Now, before I get any snippy responses, I'm willing to be an idiot,
but I've looked through the mail archives, the FAQ, the documentation
I could find, and am at a dead end. For now, I've written a message
into the servlet telling people to ignore the message, but that's bad
form.

In the archives I've found a couple of references to this problem,
e.g.
---------------------------------------------------
Anupam,

You should not ask non-development related question on the developpers
list. I don't
it's a complicated rule. Is it?

Anyway, your STDOUT appender is defined as follows.

        <appender name="STDOUT" class="org.apache.log4j.FileAppender">
           <param name="File" value="System.out" />
           <layout class="org.apache.log4j.PatternLayout">
             <param name="ConversionPattern"
                    value="%d %-5p [%t] %C{2} (%F:%L) - %m%n"/>
           </layout>
        </appender>

Log4j gives you the following warning:

log4j:WARN File option not set for appender [STDOUT].
log4j:WARN Are you using FileAppender instead of ConsoleAppender?

You should use the console appender instead, as follows:

        <appender name="STDOUT" class
="org.apache.log4j.ConsoleAppender">
           <layout class="org.apache.log4j.PatternLayout">
             <param name="ConversionPattern"
                    value="%d %-5p [%t] %C{2} (%F:%L) - %m%n"/>
           </layout>
        </appender>

Hope this helps. Please also try to play by the rules. Regards, Ceki
---------------------------------------------------

There are a couple of problems with this:

1. It relates to the use of xml configuration files
2. I'm using a properties file (see below)
3. The bulk of sample xml files use the "wrong": <appender name
="STDOUT" class="org.apache.log4j.FileAppender">
4. There's not much instructive informaiton on how to configure log4j
in general

So, does anyone have any good ideas to these:

1. How do I get rid of the log4j:WARN messages
2. How do I get started/find info. re: the more sophisticated uses of
log4j
3. etc.

Thanks for your time, sorry about the length.

  Chris Gerrard





I'm using a properties file, named logj.lcf as follows (shortened from
production, but this is real):
====
log4j.rootCategory=warn, R
log4j.appender.R=org.apache.log4j.ConsoleAppender
log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=%20c{1}:[%4L] %m%n
====

My initializing servlet:
====
import org.apache.log4j.PropertyConfigurator;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.PrintWriter;
import java.io.IOException;

public class Log4jInit extends HttpServlet {

    public void init() {
        String prefix     =  getServletContext().getRealPath("/");
        String file       = getInitParameter("log4j-init-file");
        String configFile = prefix + file;
        System.out.println("log4j: properties set using: " +
configFile);
        // if the log4j-init-file is not set, then no point in trying
        if (file != null) {
            PropertyConfigurator.configure(configFile);
        }
        System.out.println("log4j: Pay no attention to the immediately
prior two (2) \"log4j:WARN\" messages.");
    } // .. init()

    public void doGet(HttpServletRequest req, HttpServletResponse res)
{
    }
}  // .. class Log4jInit
====




--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>