Howdy,
Not currently. Because the output stream (if any!), is not associated
with a logger. It's associated with an Appender. So maybe:
Logger myLogger = ...
Enumeration myAppenders = myLogger.getAllAppenders();
Appender myAppender;
while(myAppenders.hasMoreElements()) {
myAppender = (Appender)myAppenders.nextElement();
// Iterate through, checking for FileAppenders
// for example, getting the File for each one
}
As you can see, this approach is not 100% working, as it will miss
non-File appenders that do have an output stream. And anyways, you'll
get the file and not output streams.
I think you should consider a completely different approach. Give your
objects meaningful toString() methods instead of print(OutputStream os)
methods. Create an ObjectRenderer perhaps and tie it to your loggers.
Yoav Shapira
Millennium ChemInformatics
>-----Original Message-----
>From: Pedro Salazar [mailto:[EMAIL PROTECTED]
>Sent: Tuesday, March 25, 2003 9:39 AM
>To: Log4J Users List
>Subject: get java.io.OutputStream from Logger, is it possible?
>
>Greetings,
>
>I have a method in a object that prints itself to a
java.io.OutputStream
>object:
>
>object.print(java.io.OutputStream out);
>
>To use the log4j here, I should pass through the argument something
like
>myLogger.getOutputStream() that returns the outputstream of the logger:
>
>object.print(myLogger.getOutputStream());
>
>Can I do something like this in log4j?
>
>thanks,
>Pedro Salazar.
>--
>PS
>[EMAIL PROTECTED]
>PGP:0E129E31D803BC61
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
This e-mail, including any attachments, is a confidential business communication, and
may contain information that is confidential, proprietary and/or privileged. This
e-mail is intended only for the individual(s) to whom it is addressed, and may not be
saved, copied, printed, disclosed or used by anyone else. If you are not the(an)
intended recipient, please immediately delete this e-mail from your computer system
and notify the sender. Thank you.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]