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 "Sundararaman, Anand" <An...@blr.hpsglobal.com> on 2002/11/26 08:29:51 UTC

LogFactor5

Hi,
       I have a application in which I log to a file using my own layout
class. Now we have a requirement where this log file needs to be displayed
on a gui screen.  I tried using the LogFactor5 provided by Log4j.   I could
not understand how to configure it to have my layout on the screen instead
of the default table on the screen.

Can anyone help? Or is there any other way to achieve this?

Thanks in advance
Anand
WARNING: The information in this message is confidential and may be legally
privileged. It is intended solely for the addressee.  Access to this message
by anyone else is unauthorised.  If you are not the intended recipient, any
disclosure, copying, or distribution of the message, or any action or
omission taken by you in reliance on it, is prohibited and may be unlawful.
Please immediately contact the sender if you have received this message in
error. Thank you.

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


Separate logfiles, one per client

Posted by Chris Lamprecht <cl...@mail.utexas.edu>.
I know this is a fairly common request, and I have read the log4j short
(free) manual, FAQs, and searched this mailing list's archives for the last
few months and haven't found the definitive answer to this question yet:

I run a custom-written server that serves clients, each session lasting up
to several days.  (Think of it as an instant messenger, although it does
more).  I currently use my own (custom) logging code to have one logfile per
client.  I've converted everything else over to log4j, and I'd like to use
log4j for this too.  Currently, I'm using the following code, which seems to
work:

private void setLogfile(String filename) {
    // create one log file for this client
    logger = Logger.getLogger("users." + filename);
    appender = new FileAppender(new org.apache.log4j.PatternLayout("[%d %-5p
%x] - %m%n"), filename+"2", true);
    appender.setName(filename);                // note: appender is a member
variable
    logger.addAppender(appender);
    logger.info("Starting logfile: "+filename);
}

and when the client's session ends, I do:

    logger.removeAllAppenders();
    appender.close();


Is this a decent way to handle this, or is there a cleaner way, perhaps
using MDC or NDC?  The log4j FAQ or manual hints that there is a way to do
it, but I can't find it anywhere.  Thanks for your comments, and thanks to
the log4j team for a great piece of work!

Chris Lamprecht



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