Urgent: Redirecting System.out.println to more than one place

Hi All,
I want to divert all my System.out.println() statements to a Log file as well as on to the screen.
But only one of the 2 options actually works.
So if anyone can suggest me some ways I will appreciate very much.
My code looks something like this:-
if (m_filename != null) {
try {
FileOutputStream fos = new FileOutputStream(m_filename);
PrintStream ps = new PrintStream(fos);
System.setOut(ps);
System.setErr(ps);
//This code Added for Printing Onto Screen But it does not work
Stream ps1 = new PrintStream(System.out);
System.setOut(ps1);
System.setErr(ps1);
} catch (IOException ioe) {
System.out.println("Could not create log file " + m_filename + " because " + ioe);
As far as logging onto file is menat it works when i set it but printing onto screen does not.
How can i achive it
Thanks
Raj

Hi,
You are right but in my current scenario i cannot incorporate this log4j because my application is using some other framework and I am just trying to override this frameworks loggig behaviour so that it logs to both a log file as well as on to the screen.
Here is the code that this framework uses for logging and i am simply overriding it to do the reqd thing but its not working for me:-
* Resets the System's out and err OutputStreams to the Launcher's
* own ThreadedOutputStream, so that output from different threads
* can be tracked efficiently.
protected void setOutputStreams() {
     if (scInfo.size() <= 1) {
// don't need Threaded handling with one thread
if (m_filename != null) {
try {
FileOutputStream fos = new FileOutputStream(m_filename);
PrintStream ps = new PrintStream(fos);
System.setOut(ps);
System.setErr(ps);
//Added for Printing Onto Screen
                         PrintStream ps1 = new PrintStream(System.out);
System.setOut(ps1);
System.setErr(ps1);
} catch (IOException ioe) {
Debug.fatalError("Launcher.setOutputStreams","Could not create log file " + m_filename + " because " + ioe);
else {
Debug.information("Launcher.setOutputStreams","Initializing ThreadedPrintStream");
if (m_filename == null) {
System.setOut(new ThreadedPrintStream(System.out));
System.setErr(new ThreadedPrintStream(System.err));
else {
PrintStream out = new ThreadedPrintStream(m_filename);
System.setOut(out);
System.setErr(out);
//Added for Printing Onto Screen
System.setOut(new ThreadedPrintStream(System.out));
System.setErr(new ThreadedPrintStream(System.err));
Debug.information("Launcher.setOutputStreams","ThreadedPrintStream initialized.");
Thanks
Raj

Similar Messages

  • How to use left outer join on more than one table (source)

    Hi all,
    In our project we are converting the Unix shell & SQL scripts into OWB mappings. We are facing problem converting left outer join in OWB. here is one of the example. i have just pasted the FROM and where condition.
    FROM ym_scr t1, branch_finmonth t3
    LEFT OUTER JOIN item_image t2
    ON (t1.branch_no = t2.branch_no
    AND t1.item_no = t2.item_no
    AND t3.to_date between t2.tran_dt and t2.to_dt
    AND t2.to_dt >= '$start_images' ) <<<========= '$start_images' THIS COMES FROM THE UNIX VARAIBLE ,
    We converts the same when we are putting it in OWB join Operator
    INGRP1.branch_no = INGRP2.branch_no(+)
    AND INGRP1.item_no = INGRP2.item_no(+)
    AND INGRP3.to_date between t2.tran_dt and t2.to_dt
    AND INGRP2.to_dt >= INGRP2.start_images
    But as you see in the OWB opreator we can put left join with INGRP1 with INGRP2.
    We can not make same join with INGRP3 & INGRP4 , becoz it failed saying "you cannot left outer join on more than one table/source".
    so overall this OWB code makes incomplete left outer join as per the above ANSI SQL join in Oracle.
    Bcoz of the problem we are getting less number of rows...........
    SO please please help me on this
    Regards
    Ashok

    Hi.
    I know this topic is here for a while now, but I had the same problem today, searched for help and didn´t find anything.
    Later I figured out how to do this.
    You just have to put the (+) one time, and the OWB converts in an LEFT OUTER JOIN statement.
    For this case, all you have to do is:
    ( INGRP1.branch_no = INGRP2.branch_no(+) AND INGRP1.item_no = INGRP2.item_no AND INGRP2.to_dt >= INGRP2.start_images )
    Regards,
    Godoy

  • Redirect system.out.println() to a file

    hi all,
         how can i redirect all the console prints to a txt file in java application? i have used system.out oftenly in many class throught the
    application. is there any way to redirect all those console prints to a
    txt file by converting or assigning the System.out stream to a stream for filewriter or
    somthing like that, so that whenever system.out.println() is executed
    the content is written to a file insted of on the console.
    thanks in advance
    Sojan

    Actually,System.setOut(new PrintStream(new FileOutputStream("output.txt"), true));
    System.setErr(System.out);since setOut wants a PrintStream and not just some OuputStream...

  • Oracle OUTER JOIN on more than one table

    Hi!
    Friends, please help with this urgent problem: How can an outer join be written on more than one table?
    An SQL Server query:
    SELECT * from a INNER JOIN b on a.id = b.id LEFT OUTER JOIN c ON c.id = a.id AND c.id = b.id
    works fine with SQL SERVER
    But Oracle query:
    SELECT * from a,b,c WHERE a.id = b.id AND a.id = c.id (+) AND b.id = c.id (+)
    gives an error: OUTER JOIN cannot be used on more than one table? Why?
    I use OracleDriver from classes12.zip to connect to Oracle8i database.
    Please, help!

    The Oracle 8i and later SQL reference reads that the following "join_types" are supported and under this syntax it does not limit the LEFT OUTER JOIN (syntax the same as SQLServer example in original note) to two tables as implied in these notes:
    The join_type indicates the kind of join being performed:
    Specify INNER to indicate explicitly that an inner join is being performed. This is the default.
    Specify RIGHT to indicate a right outer join.
    Specify LEFT to indicate a left outer join.
    Specify FULL to indicate a full or two-sided outer join. In addition to the inner join, rows from both tables that have not been returned in the result of the inner join will be preserved and extended with nulls.
    You can specify the optional OUTER keyword following RIGHT, LEFT, or FULL to explicitly clarify that an outer join is being performed.

  • Digitally signing a PDF doc in more than one place by one signatory.

    We sent contracting individual's a PDF version of agreements for signature. THey currently print, sign and return.
    The document contains more than one agreement, so needs signing in 6 or 7 places.
    Is it possible to pre-locate the place/s where the electronic signatures can be placed when designing the pdf documetns, so that a recipient can 'sign' it once, but all the necessary places show the 'digital' signature?
    I expect not, and that the solution is to prepare a digital signature only version of the docs that needs signing in only one place.
    Thanks
    John

    Hi Peter,
    Believe me that I know as well as anyone how complex PKI can be. No matter how simple we try to make adding a digital signature in Acrobat/Reader there are some immutable facts. One of those is we have to absolutely, positively guarantee that the digital signature covers exactly what the signer intended. The only way to do that is commit the signed bytes to disk before completing the signature, and that requires a Save operation. Early on when digital signatures were first introduced in Acrobat we did do the signing operation on the bytes in memory, but the risk was too great for someone slipping in bytes that the signer did not intend to sign. If there were no bad guys we could get away with signing in memory, but alas, the risk of data compromise is too great to do that today. If we were to go back to that method we would be excoriated by the cryptographic community for allowing a hole into which bad data could be injected.
    Beginning with Acrobat/Reader 9 we did change the UI so if there is nothing other than a subsequent signature the change won't be as obvious. The user would have to dig into the Signature Navigation Panel in order to track down the change.
    Steve

  • How to resrict purchaser accept more than one RFx response ?

    hi all
      we use SRM 7.0 with standalone scenario.
      when the purchaser carry out Response comparison , system permit purchaser accept more than one bidder for one RFx item . the result is we want material A 10 piece, but supplier X and supplier Y get PO for 10 piece material A each.
       we want to restrct this operation, please give me some advices, thanks.
      regards
        claud

    You might want to try restricting at the PO creation time. Implement BBP_DOC_CHANGE_BADI for PO (BBP_PO_CHANGE method). In the logic, check the related proceeding RFx's item total quantity against its existing follow-on POs' item quantity. If adding the quantity of the current  PO exceeds the total RFx item quantity, throw an error to prevent the current PO from being created.

  • How to restrict more than one delivery from one sales order.

    Hi Guys,
    We have a requirement that is, system should not allow more than one delivery from one sales order no even if when there is some line item still to be delivered.
    We want only one delivery for one sales order and rest of line items should be treated as rejected.
    Kindly help
    Thanks in advance,
    Balu

    Hi MP,
    Its also not working as we have the requirement is that once sales order is saved and one delivery is created then again if we are adding some more item inthe same sales order then system should not allow to create delivery document as one delivery already created.
    Thanks,
    Balu.
    Edited by: Balu Sajja on Aug 30, 2010 1:29 PM

  • Select  More than one Data Source in UM Configuration

    hi,
    We configure our portal EP 6.0 with the CRM Dev system, such that the users created in CRM Dev system reflect in portal as well.
    now the problem is in CRM Test system. when we create users, users are going to create in CRM test system.but our portal is configured with CRM Dev system.
    is there any way to configure portal with both CRM Dev system users and CRM test system users.
    thanks

    See Select More than one Data Source in UM Configuration

  • ChaRM: Support of more than one transport layer

    Hi!
    We would like to implement ChaRM for the 3 tier landscape (DEV:100 --> QAS:200 --> PRD:100) with several transport layers and transport routes:
    a) u201CZDEVu201D u2013 Standard transport layer
    b) u201CSAPu201D u2013 SAP transport layer
    c) u201CYCSTu201D u2013 transport layer for internal customizing
    d) u201CZEXTu201D u2013 transport layer for external vendor
    All the transport layers should be used for the transports from DEV:100 to QAS:200 within ChaRM.
    Our question:
    Does ChaRM support several transport layers (SAP and none-SAP)?
    Or does it accept only standard transport layer
    (u201CSAPu201D and u201CZDEVu201D, but it doesnu2019t support u201CYCSTu201D and u201CZEXTu201D)?
    Thank you very much!
    regards

    Hi
    ChaRM only supports one (the standard) transport layer per client. I've already told you that some days ago... You can trust me I've configured those landscapes several times for many customers.
    Enclosed please find a statement from SAP:
    Transports are supported in the standard transport layer of each client. When you configure transport routes, note that only consolidation routes that are assigned to the standard transport layer of the relevant exporting client are taken into consideration. For each exporting client, exactly one target client and one target group are permitted.
    We recommend that you assign exactly one development system to a production system, and that these two systems are connected by exactly one unique transport track.
    If a development system and a production system are connected by more than one transport track, this may lead to inconsistencies within the transport distribution. This type of transport configuration cannot be supported by Change Request Management, and may cause inconsistencies within the tools involved.
    So you have to change your TMS configuration and the assignment of transport layers to development packages. e.g. use transport layer SAP and ZDEV
    Then it is possible to use ChaRM and standard TMS together
    regards
    Andy

  • More than one Apple TV unit in a household?

    I want to know if I can use a second Apple TV in my house. I have one in the living room, but want one in my bedroom, and don't think it's a good idea to keep moving/unplugging cables from this unit. That can't be good for it in the long run. Anyone else out there using more than one unit in their house?
    And if so, can both of them be used at the same time? For example: watching Netflix in one room, and something from iTunes Library in the other. Or even Netflix in one room and something different on Netflix in the other room.
    Thanks.

    Thanks, I wanted to be sure before I shell out another hundred bucks!

  • Customer Master: Communicatio method more than One mail ID

    Hi All,
    I have a requirement here:
    In the customer master - General data - address - communication method
    My user want to maintain more than one e-mail id, i see system allows to insert more than one id.
    Requirement: User want system to send ex: order confirmation to all the IDs that are maintained in the customer master.
    Issue: I see in the customer master after I insert the mail ID there is a radio button which restricts to only one ID where the communication to be sent.  
    Help: Any one got some idea how I can fulfil this requirement please?
    Yash

    hi
    this is to inform you that
    create a Z table woth maintaince view with authorized personall only.
    where you can have/maintain n number of mail ids of the users.
    and
    two function modules are available for the same one is old and anothre is new function modules provided by SAP.
    when ever you want to trigger a email you have to call the z table.
    then it triggers automatically.
    regards
    balajia

  • Print System.out.println messages into logs of Weblogic Application Server

    Hi,
    I use Weblogic Application Server 10.3.6 on Windows 7. The Enterprise Application (J2EE) is deployed into the 'AdminServer' of Weblogic. For debugging purpose, I have added a few System.out.println statements.
    I am unable to see the print messages on any of log files available in path 'user_projects > domains > base_domain > servers > AdminServer > logs'. However, I can see them on the 'command' prompt which was used to start the server. How can I get them into one of the log files? What am I missing?
    I tried reading other threads on the forum and as per them 'System.out.println' gets logged onto *.out logs which I am unable to find. Only base_domain.log, AdminServer.log, access.log are available in the location.
    More Specifics:
    Configuration on WLS console 'Home > Servers > AdminServer > Logging'
    Log file name: logs/AdminServer.log
    Min. Severity to log: Notice (tried with Debug as well)
    Advanced Options:
    Logging Implementation: JDK
    Redirect stdout logging enabled: False (tried both options)
    Log file Severity Level: Notice (tried with Debug as well)
    Standard Out Severity Level: Notice (tried with Debug as well)
    Thanks

    Paul,
    I just found this on google:
    'Generally, developers put a lot of System.out.println statements in their code to perform application debugging. Normally, all standard outputs and error outputs are routed to the console where the OC4J server is started. If you want to capture the standard output and error outputs to files for logging/debugging purposes, then you can use the -out and -err options while starting up the Oc4J server to specify which files to use.'.
    http://www.onjava.com/pub/a/onjava/2002/01/16/oracle.html?page=2

  • System.out.println not showing up in the console

    Hi,
    I've some System.out.println statements in a static block in a Stateless
    Session Bean. I could not see these outputs in the Weblogic console. I'm
    using Weblogic 5.1 Any one faced this problem before? any help is
    appreciated.
    Thanks & Regards,
    Nithi.

    Take a look in the weblogic log files they might be redirecting std out.
    "Ryan LeCompte" <[email protected]> wrote:
    >
    Hello Nithi,
    I'm all out of ideas, unfortunately! However, check out the following
    links for
    some possible insight into the problem:
    http://groups.google.com/groups?q=System.out.println+5.1+WebLogic&start=60&hl=en&lr=&ie=UTF-8&oe=UTF-8&selm=3d3df18e%40newsgroups.bea.com&rnum=69
    http://groups.google.com/groups?q=System.out.println+5.1+WebLogic&start=70&hl=en&lr=&ie=UTF-8&oe=UTF-8&selm=3977417b%40newsgroups.bea.com&rnum=71
    http://groups.google.com/groups?q=System.out.println+5.1+WebLogic&start=200&hl=en&lr=&ie=UTF-8&oe=UTF-8&selm=3bc20346%241%40newsgroups.bea.com&rnum=209
    Best regards,
    Ryan LeCompte
    [email protected]
    http://www.louisiana.edu/~rml7669
    "Nithi Rajan" <[email protected]> wrote:
    Hi Ryan,
    Thanks for your reply and sorry for the long silence. I was on vocation.
    Thre problem still remains.I'm very sure that the EJB
    is deployed by WebLogic as I'm able to call some methods.
    and I'm also calling EJB methods from Servlet. But my
    System.out.println statments work fine in the Servlet and
    not inside EJB (or anyother classes used by EJB).
    Any one has faced similar problems? BTW am using WebLogic 5.1
    Thanks in advance,
    Regards,
    Nithi.
    "Ryan LeCompte" <[email protected]> wrote in message
    news:[email protected]...
    Hello Nithi,
    I find it strange that your System.out.println statements are beingexecuted from
    within your servlets, but not in your stateless session bean. Are
    you
    positive
    that your EJB is being located and deployed by WebLogic? The statementsin
    your
    static { } block should be executed as soon as the WebLogic class
    loader
    finds
    the class and loads it into the JVM. I would suggest examining theconsole
    and
    try to determine if your EJB is in fact being deployed. Are you invokingmethods
    on the EJB inside of your servlets? Are you using any logging frameworkfrom within
    the EJBs which would redirect output to a file?
    Best regards,
    Ryan LeCompte
    [email protected]
    http://www.louisiana.edu/~rml7669
    "Nithi Rajan" <[email protected]> wrote:
    Hi Ryan,
    Thanks for your reply. The setting in the weblogic.properties is
    as
    follows.
    weblogic.system.enableConsole=true
    So, that tells me that I should see all the System.out.printlns right?
    (Pleasecorrect me if I'm wrong). I can see all the System.out.println
    from
    my
    servletand not from the Session Bean (even if the System.out.println
    is
    outside
    static block).
    Please let me know your thoughts.
    Thanks & Regards,
    Nithi.
    "Ryan LeCompte" <[email protected]> wrote in message
    news:[email protected]...
    Hello Nithi,
    Are you sure that you don't have WebLogic configured to redirect
    all
    messages
    to a file instead of the console? Are you able to see yourSystem.out.println
    statements when placed within other methods of your stateless sessionbean? Please
    be a bit more specific.
    Thank you,
    Ryan LeCompte
    [email protected]
    http://www.louisiana.edu/~rml7669
    "Nithi Rajan" <[email protected]> wrote:
    Hi,
    I've some System.out.println statements in a static block in a
    Stateless
    Session Bean. I could not see these outputs in the Weblogic console.
    I'm
    using Weblogic 5.1 Any one faced this problem before? any helpis
    appreciated.
    Thanks & Regards,
    Nithi.

  • Linux System.out.println()

    I am porting some JSP's from Windows to SUSE Linux. These JSP's call functions that are embedded in JAVA classes, which in turn output error messages with System.out.println() to the console. It appears that in Linux, the bash Konsole doesn't print these errors, so they are invisible.
    I suppose that if I wrote JSP's in the future, errors could be printed in the browser, but I would really like to be able to see my errors in bash or which ever shell. Any help would be appreciated.

    If you ever intend to use more than one webserver, I would suggest you look towards something like JMS. Messages can be sent to the queue from which you can pick them up and deal with them as necessary in your own time, be that real-time or delayed.
    If you think you will never need more than one, why not write a little log file reader? Remember though that the catalina.out file will grow and grow unless you stop Tomcat, rename the old file and restart Tomcat.

  • Is there a way to make system.out.println() scroll down as it goes?

    I am writing a program where I want to be able to read what's printed out in the console of my IDE through System.out.println() as the program runs/after the program runs. However, right now I run the program, the message prints out, and then when I go to read it the scroll bar is all the way up so I can see only the top of the print-out (the first thing printed out). Is there any way I can get the console to scroll along with the text, kind of like floating boxes you see on various websites for various reasons? In other words, can I get it so that when I look in the console at any given moment of the program running, I am looking at the newest text printed out (the text at the bottom of the "page")? Thank you!

    That would be an IDE problem and not a Java one. You could redirect output into a text file so you can read at your leisure and scroll up and down as much as you like.

Maybe you are looking for

  • Subscription expires...How do I extend?

    I got an email from Skype that my online number is about to expire. But I don't find any option in my account to extend the online numbers, how do I do that? Helmut Petersen

  • How to bounce into MP3 with the names of an artist and song

    Hi again) I bounce my projects to mp3 successfully but I cannot find the way to put my name and name of the song to mp3 file properties!!! And I failed to assign titles to the file in Mac OS... it was so easy in Windows - right click!!)))) Help me pl

  • Impossible d'acheter un livre !

    j'ai conçu un livre de 100 pages avec Iphoto'1 et veut l'acheter. Impossible car le message suivant apparaît depuis deux jours : "Une erreur est survenue lors de la communication avec l'Apple Store en ligne. Veuillez réessayer." Que faire ?

  • Convert native EDI to EDI xml

    Hi All, Is there any API or easy method to convert a native EDI to EDI xml...and vice versa ??? Regards, Praveen

  • Can't send mail one answer

    Ok this is my first post here and I refer you to another forum that contains one guy's solution to the can't send mail question: http://www.macfixitforums.com/php/showflat.php?Cat=&Board=Forum36&Number=757755& page=0&view=collapsed&sb=5&o=21&fpart=1#