Tomcat Java Servlets, how to log System.out.println() messages

I have recently installed a new (x86) Mac OS Xserve, and am porting some Java application Servlets from an existing older Mac OSX server. All the servlets were working (I am connecting via port 9006). I have carefully used the old JDK 1.4 compiler, edited my server.xml (for port 9006) and web.xml files, etc. The Tomcat example servlets work fine, and all my (other) servlets work fine, with one exception, where I get the typically vague "java.io.IOException: Server returned HTTP response code: 500" message.
Trouble is, I cannot get the Java System.out.prinln statements to go to the Tomcat/logs/ log files (they are all there and updating with Tomcat HttpServlet messages), in order to properly debug.
Is there a server.xml value somewhere I can make the change?
On another minor (possibly related) point, does anyone know what the path info ='null' means in the Tomcat access log? e.g.,
StandardContext[/my_servlets]: Mapped to servlet 'myServlet' with servlet path '/myServlet' and path info 'null'
It is the only other suspicious message I get in all the logs.
One other point: my java application that fails uses threads. All the individual classes that use the threads work when run interactively, but as soon as I call them from final Serlet class that extends HttpServlet, I get a null pointer exception. Is there something unique about the Tomcat 4.1 threading that could be causing it?
I want to avoid upgrading to Tomcat 5 at this point, if I can avoid it. My applications are modest in scope, and the last time I upgraded to Tomcat 5, it took me days to get it working properly, and I lost all access to it from the Server Admin application.

I have found a solution: Via the Tomcat Admin web page I set the Context field "Swallow Output" to "true".

Similar Messages

  • How to view System.out.print() messages for adapters in OIM 9.0.3

    I have created an adaptor for OIM from a java jar file. When that adaptor executes after some updates on tables it produces some execptions/error.
    I can not see the details of these exceptions as I do not know where is the standard output located when adapter is executed via OIM.
    Where cen I see output from my code lines that contain: System.out.println()?
    thanks

    I am not sure if logging is enabled as OIM was installed previously by another person - how can I check if it is enabled and how to use log4j in this case?
    OIM Design Console window shows no messages comming from my System.out.print() statements.
    /br
    Djeno

  • 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

  • How to replace System.out.println() using templates

    can you give the complete code for my problem which is given below.
    package include;
    public class P
    public static cout(int a)
    System.out.println( a);
    public static cout(int a,int b)
    System.out.println(a + b);
    // like this i need to write to accept parameters from the class. which is importing this package
    for some more examples
    public static cout(int a,String s)
    System.out.printn(a +s);
    and many more type i.e. all types of arrangements of datatypes
    the above is the package called "include" Now Iam Importing the package in the class Hello:
    import include.P;
    public class Hello
    public static void main(String args[])
    int i=10;
    float f=12.23;
    String s="hello";
    P.cout(i,f); //cout is the static method of package(include) class " P"
    P.cout("welcome",s)
    // like this I want to send any type and any no of arguments as the System.out.println()
    will handle.
    My aim is to replace the System.out.println() with P.cout() which can be achieve in my idea by calling the static method ( such as cout() ) which internally use System.out.println() method. I am facing problem in achieving this because we donot know which type and how many parameters he will send .
    My task is we have to create a method which will accept any no.of arguments and is of any type.I think this can be done BY USING TEMPLATES.
    So please understand my problem and send me reply.I am waiting for your reply.
    thank you.

    Although I am not sure why you are doing this, if you really are trying to code a replacement for System.out.println then:
    out is a PrintStream and the println methods of PrintStream have the following signatures:
    void println()
    Terminate the current line by writing the line separator string.
    void println(boolean x)
    Print a boolean and then terminate the line.
    void println(char x)
    Print a character and then terminate the line.
    void println(char[] x)
    Print an array of characters and then terminate the line.
    void println(double x)
    Print a double and then terminate the line.
    void println(float x)
    Print a float and then terminate the line.
    void println(int x)
    Print an integer and then terminate the line.
    void println(long x)
    Print a long and then terminate the line.
    void println(Object x)
    Print an Object and then terminate the line.
    void println(String x)
    Print a String and then terminate
    So you should only need to create corresponding methods.

  • Where to see the System.out.println() messages

    I deploy my application in Oracle9ias . I have some System.out.println() statements in java class files.
    When I run the application I need to know where I can see those println() statements.

    The Member Feedback forum is for suggestions and feedback for OTN Developer Services. This forum is not monitored by Oracle support or product teams and so Oracle product and technology related questions will not be answered. We recommend that you post this thread to the Application Server-General forum. The URL is:
    Oracle Application Server - General

  • How to get System.out msg displayed in logs

    Running SJSWSEE6.1 SP5 on Solaris
    How do I get the System.out.println messages to display in the Web Server 6.1 error/access log??
    Thanks..

    Hi,
    In your server.xml, check that the properties 'logstderr' and 'logstdout' are set to 'true'. The messages will then appear in the errors log file.
    <LOG file="<path to errors file>" loglevel="info" logtoconsole="true"
    usesyslog="false" createconsole="false" logstderr="true" logstdout="true" logvsid="false"/>
    Also, see docs at http://docs.sun.com/source/817-6248/crsrvrx.html
    Hope this helps.

  • Java Beans System.out.println Log file

    Helllo,
    I have Forms 11.1.2 installed on linux. I developed a java bean and put some System.out.println() statements. The bean itself is working but where do i look for the debug statement logs that i am generating via System.out.println() statements.
    Please let me know if you need more information, I will post asap.
    thanks in advance,
    Prasad.

    Prabodh,
    thanks, added the following line to the implementation class in java bean:
    private final static Logger logger = Logger.getLogger(MyBean.class.getName());
    and then in the init() method, i put
    logger.info("Prasad .... in init);
    Does this automatically goes into weblogic managed server WLS_FORMS (in my case) standard out?
    Or do i need to do anything else, i know weblogic comes up with its own diagnostic logging and is famous for supressing other loggers.... just want to run this by you as well.
    thanks,
    Prasad,

  • 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.

  • Changing System.out.println()

    Imagine having hundreds of java classes. In these classes there are many System.out.println(data) in different places. When printing in the console screen I cannot know which java class is printing. Of course I could open every java-file and in every System.out.println() write as:
    System.out.println("This is TheNameOfJavaClass" + myData)
    or
    System.out.println(this.getClass().getName() + " - " + myData)...but I want a nice approach like extending or implenting some how in classes and the java classes add java-class-name when using System.out.println(myData) it becomes className + myData
    Do you have any suggestion? Is there clever approach to this?
    Edited by: Maria1990 on Aug 12, 2010 12:32 PM

    You may have missed the first reply, so here just an example:
    import java.io.PrintStream;
    public class PrefixPrintln {
        private static class Prefixer extends PrintStream {
         public Prefixer(PrintStream ps) {
             super(ps);
         @Override
         public void println(String txt) {
             super.println(findCaller() + ": " + txt);
         // I'm not sure if other print methods will invoke println(String),
         // so you may have to overwrite other print methods as well.
         private String findCaller() {
             StackTraceElement[] elms = Thread.currentThread().getStackTrace();
             for (StackTraceElement elm : elms) {
              String name = elm.getClassName();
              if (!name.equals(this.getClass().getName())
                   && !name.equals(Thread.class.getName())) {
                  return name;
             return null;
        public static void main(String[] args) {
         System.setOut(new Prefixer(System.out));
         new PrefixPrintln().useSystemOut();
        private void useSystemOut() {
         System.out.println("Some message");
    }

  • System.out.println()'s inside implementation

    Hello,
    We all know the System.out.prinltn() API. But I want to know the inside implementation of System.out.println() API. Where can I get this implementation?
    Furthermore, can anyone explain concretely about how to implement System.out.println()? Can you tell me in a great detail?
    JohnWen604
    21-June-2005

    I just cannot understand what is the magic behind
    d that one API can control the hardware(i.e. control
    the screen to print one "simple" sentance). Do youIt's called "native OS methods". And you're not controlling anything, the graphics driver does. You're just asking the OS to ask the driver to ask the graphics card to send the appropriate signals.
    think that is just just the magic of our grand new
    computer? So If I can fully understand how the
    hardware is controlled by the Application Program, I
    will be more sensible in writing software. Just likeI doubt that. The more sensible way would be to stick to a useful level of abstraction and good design.
    you know the IC's inner structure if you want to be
    an qualified Electronic Engineer. Do
    you think so?No.
    Besides, from some OS books I know that
    w that Application program written in Java will
    become some OS commands that is ready for going
    through the OS's command processor. I just do not
    understand how that primitive Java code is written
    which is OS command and can tell hardware(screen) to
    print something. Do you know what that primitive Java
    code is?-- The primitive Java code that is a OS
    command to tell screen to print something. The
    primitive java code 's examples are "+", "for",
    "while", "private". The primitive java code does not
    mean API.No. It's called "instructions".
    What you said about setOut0(), I think
    setOut0() is simply an API. Do you know the
    implementation of this setout0() API? There must be
    implementation and there must be the primitive Java
    code. Do you agree with me?No. It's N-A-T-I-V-E. No Java code. Nowhere. Just C++ or whatever.

  • Explain each term  System.out.println ( ) ?????

    Hi friends,
    I am new to java,
    can u explain about System
    out
    println
    I know System is class and what about out
    so class.class is possible ?
    can u explain each term
    plz
    it will help me in interview facing also.

    almost
    Out is a variable of PrintStream ( PrintStream out
    = new PrintStream() )I assume you meant the correct thing, but wrote the wrong one:
    out (note that it's lower case) is a public final static variable of the class System and it's of the type PrintStream.

  • NullPointerException in out.println(message);

    Am trying to send a String to a server but getting a NullPointerException on line 46 thats this line:
    out.println(message);
    the code :
    import java.sql.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.applet.Applet;
    import java.io.*;
    import java.net.*;
    import java.util.*;
    import java.applet.AudioClip;
    import javax.swing.text.html.*;
    import java.net.URL;
    import java.io.IOException;
    public class chatClient extends JApplet implements Runnable
    private String hostname, message;
    protected BufferedReader in;
    protected PrintWriter out;
    protected TextArea output;
    protected TextField input;
    protected Button b;
    protected Thread listener;
    // Constructor looks after GUI
    public chatClient()
    //super("Chat Client");
    getContentPane().setLayout(new BorderLayout());
    output = new TextArea();
    // Panel to arrange two components on
    Panel p = new Panel();
    p.setLayout(new BorderLayout());
    input = new TextField();
    b= new Button("Send");
    // What happens when we press the button...
    b.addActionListener(new ActionListener(){
    public void actionPerformed(ActionEvent e)
    // read in text from textField, store as string
    message = input.getText();
    out.println(message);
    System.out.println("Message is:" + message);
    //out.flush(); We set the boolean autoflush to true in constructor
    // blank the textField for next line
    input.setText(" ");
    }); // ends inner class
    // add the textfield and button to the Panel
    p.add("North", input);
    p.add("South", b);
    // add the textArea and the Panel to the Frame
    getContentPane().add("Center", output);
    getContentPane().add("South", p);
    // the 'engine' behind the GUI
    public void runClient()
    // set hostname to 127.0.0.1 for testing
    hostname="localhost";
    // try to create the socket and initialise the Streams
    try
    Socket s = new Socket(hostname,9999);
    in = new BufferedReader(new InputStreamReader(s.getInputStream()));
    out = new PrintWriter(s.getOutputStream(),true);
    output.append("Connected to Server...\n");
    catch(UnknownHostException e)
    System.err.println(e);
    catch(IOException e)
    System.err.println(e);
    // initialise a listener thread to catch messages from server
    listener = new Thread(this);
    listener.start();
    System.out.println("Listener started");
    // listener.start() creates a thread which calls run()
    public void run()
    // just loop reading the input stream
    try
    while(true)
    String line = in.readLine();
    System.out.println("Received from Server:" + line);
    output.append(line + "\n");
    catch(IOException e)
    System.err.println(e);
    // when the Thread is killed...
    finally
    listener = null;
    input.setText(" ");
    out.close();
    public static void main(String args[])
    chatClient c = new chatClient();
    c.runClient();
    Can someone show me the way?

    Yes positiv this is how my server looks try for your self :
    import java.net.*;
    import java.io.*;
    import java.util.*; /* we need a vector to handle unknown numbers of connections */
    public class chatServer
    public chatServer() throws IOException
    /* we're not too bothered about the exception details, so
    we'll acknowledge it here instead of writing lines of
    code to analyse it */
    // initialise new ServerSocket
    ServerSocket s = new ServerSocket(9999);
    // loop listening for connections and instantiate a new handler for each one
    while(true)
    Socket client = s.accept();
    System.out.println("Accepted connection from " + client.getInetAddress()+":"+ client.getPort());
    chatHandler c = new chatHandler(client);
    c.start(); // chatHandler is derived from Thread, so we can call start()
    public static void main(String[] args) throws IOException
    chatServer cs = new chatServer();
    } // end class definition
    // define class chatHandler as a derivation of Thread
    class chatHandler extends Thread
    // declare variables
    protected Socket s;
    protected BufferedReader in;
    protected PrintWriter out;
    protected static Vector handlers = new Vector();
    public chatHandler(Socket s) throws IOException
    // assign socket passed to object to class variable s
    this.s = s;
    // initialise streams
    in = new BufferedReader(new InputStreamReader(s.getInputStream()));
    out = new PrintWriter(s.getOutputStream(), true);
         System.out.println("Readers and Writers initialised");
    public void run()
    System.out.println("run called");
    try
    // add this thread to class variable vector
    handlers.addElement(this);
              System.out.println("Element added to Vector");
    // loop reading input and passing it to broadcast method
    while(true)
                   System.out.println("About to read inputstream");
    String message = in.readLine();
                   System.out.println("Input Stream read");
                   System.out.println(message);
    broadcast(message);
                   System.out.println("Message passed to broadcast method");
    catch(IOException e)
    System.err.println(e);
    // if this thread is killed....
    finally
    // remove it from the vector
    handlers.removeElement(this);
    try
    // tidy up debris!
    s.close();
    catch(IOException e)
    System.err.println(e);
    // this static method is used by all threads
    protected static void broadcast(String message)
    /* to prevent two threads trying to access the vector
    simultaneously we use a synchronized block */
         System.out.println("Broadcast called");
    synchronized(handlers)
    /* The Enumeration interface gives us a quick way of looking at
    a vector which by definition is an unknown length */
    Enumeration e = handlers.elements();
    // returns true if there are other sockets running
    while (e.hasMoreElements())
    // loop to the next chatHandler in the vector
    chatHandler c = (chatHandler) e.nextElement();
    // write the message to it
    try
    /* prevent two threads trying to write
    to the stream c.out */
    synchronized(c.out)
    c.out.println(message);
    } // end synchronized block
    //c.out.flush(); we set the boolean autoflush to true in the constructor
    catch(Exception ex)
    System.err.println(ex);
    // explicitly stop the thread if exception is thrown
    c = null;
    } // end while loop
    } // end synchronized block
    } // end broadcast
    } // ends class

  • How to :Logging or System.out.println????

    Hi,
    Iam not able to see any System.out.println output in SAP? where exactly can i see it? any configuration required to enable logging? if so how?? please help

    Hi Sujesh,
    see https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/events/webinars/using logging and tracing on the sap web as java.pdf pages 12-17 and pages 22-24.
    Also see http://help.sap.com/saphelp_nw04/helpdata/en/e2/75a74046033913e10000000a155106/frameset.htm for portal specific logging issues.
    Hope it helps
    Detlev

  • Tomcat Servlet: System.out.println in servlet not printing to catalina.out

    Hello friends ,
    When i m using System.out.println() in servlet its o/p should come in catalina.out but its not coming plz help me....one thing more can we replace exixting catalina.out file with new one...
    please Help me soon.
    Thanks

    go to[u] TOMCAT_DIR/config/server.xml.
    Open this xml file and find something like <Logger className="org.apache.catalina.logger.FileLogger"
                  prefix="catalina_log." suffix=".txt"
                  timestamp="true"/>and
    <Logger className="org.apache.catalina.logger.FileLogger"
                     directory="logs"  prefix="localhost_log." suffix=".txt"
                timestamp="true"/>You can change the log file name to another one.
    It's much better to use a logger tool like log4j (http://logging.apache.org/log4j/docs/download.html) then using a System.out.println()...
    hope that helps

  • How can I see whatever I print through System.out.println in my servlets when I use iplanet 4.1

    how can I see whatever I print through System.out.println in my servlets when I use iplanet 4.1

    Hi Nitin,
    Look out the below link, Hope this helps you.
    http://knowledgebase.iplanet.com/ikb/kb/articles/4235.html
    http://knowledgebase.iplanet.com/ikb/kb/articles/4790.html
    http://knowledgebase.iplanet.com/ikb/kb/articles/4699.html
    Regards,
    Dakshin.
    Developer Technical Support
    Sun Microsystems
    http://www.sun.com/developers/support.

Maybe you are looking for

  • MAC Mini and Sony TV LCD  question

    In the past, when I connected to my Sony projector tv, unable to use the highest setting because lost part of the desktop with icons on bottom and entire top bar. New Sony LCD used and same thing happening. I am using a HDMI connection on the Apple.

  • IPod touch random crashing

    I just upgraded from a 3G 40GB iPod to a brand spankin' new 16Gb iPod touch, and I'm noticing some random weirdness with it. First a few details: *- At this moment I have 969 songs, 1 video, and 4 photos loaded on my iPod touch, leaving 3.9GB free.*

  • Poor print quality for black ink for Photosmart 6520e

    Having a problem with black printing.  Using all HP cartridges, but when I run a test page, I get white, horizontal bars across the black test bars.  Some of them are 1/4 inch wide.  Replaced the cartridge and did the automatic printhead cleaning, bu

  • Time Capsule 'Unavailable'

    I back up 2 machines to my Time Capsule: one is hooked up by ethernet, the other by Airport (a PPC iMac). The Airport machine's back up failed with the error message: 'The backup disk could not be mounted.' I can see and access the Time Capsule in th

  • Automatic incidents in Solution manager

    Hello all, At first, I am not SolMan consultant...so maybe my issue is not so difficult for you. Customer use FM AI_CRM_IM_INCIDENT_CREATE to automatically create incidents in some cases. They added some customer fields to the incident (message type