Re: Logger inputs only to STDOUT?

From: Arvind (asrinivasan_at_worldbank.org)
Date: 04/28/04


Date: 28 Apr 2004 07:37:54 -0700

One other way of doing it is to use appenders - appenders come in
different flavours - the default i guess is ConsoleAppender - as the
name indicates is stdout logger...

there is one more appender called FileAppender (or something like
that) - which then defines the file path where you want the log to be
directed to....

needless to say there is a property file which acts as the config and
gets loaded by the log4j package on startup and this property file
needs to be in the classpath....

Arvind
"I dont have any quotes..."

"Liz" <Liz@nospam.com> wrote in message news:<Hjlic.11159$0u6.1994322@attbi_s03>...
> "Spare Brain" <spare_brain@yahoo.com> wrote in message
> news:c6cg1b$d5o15@kcweb01.netnews.att.com...
> > Hi,
> >
> > Even though the code defines an output file when initializing the
> > java.util.Logger, the output always goes to the stdout. The application is
> > part of a WebLogic application. What needs to be done to change this
> > behavior? Any suggestions/hints?
> >
> > Here's how the code looks:
> >
> > protected final Logger logger =
> > Logger.getLogger(System.getProperty("java.logger.logDir", "./logs") +
> > System.getProperty("file.separator") + getClass().getName() + ".log");
> > ...
> > ...
> > ...
> >
> > if (logger.isLoggable(Level.INFO)) {
> > logger.info("Executing static SQL query '" + sql + "'");
> > }
> > ...
> > ...
> >
> >
> Here is what I do and it works in my vanilla application.
> --------------------------------------------------
> static Logger logger = Logger.getLogger("global");
> // default is one parent handler and that is console at level INFO
> logger.setUseParentHandlers(false); // turn off the default handler
> // create a 'file' handler (default level = ALL)
> fh = new FileHandler("myAppLogFile%g.log", 50000, 10, false);
> fh.setFormatter(new SimpleFormatter()); // set the formatter
> fh.setLevel(Level.INFO); // change level if you want to
> logger.addHandler(fh); // add the handler
> --------------------------------------------------
> HTH
> Liz....