Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Servlet won't write logs

Options
  • 15-04-2005 12:13pm
    #1
    Registered Users Posts: 451 ✭✭


    Hi All,

    I developing java servlets using eclipse with Tomcat plugin on a tomcat server on my PC. I'm trying to get the log method to work, but nothing is in the server directory. EG

    this.log("This is a message in the log.\n);

    Anyone any ideas?

    Thanks,
    LK.


Comments

  • Registered Users Posts: 640 ✭✭✭Kernel32


    Never used java servlets or Tomcat but problems like this in a web environment normally come down to permissions. Does the user the webserver is running as have write permissions to the directory you expect to see the log file in?


  • Registered Users Posts: 3,312 ✭✭✭mr_angry


    I'm not really an experienced Java programmer myself, but I generally use my own debugging function, something like the following:
    private void debug(String strVariableName, String strValue)
    {
            try
    	{
    		//Open the file in 'append' mode.
    	    	BufferedWriter out = new BufferedWriter(new FileWriter("D://somepath//somefile.log", true));
    		    	
    		out.write("The vaule of "+ strVariableName +" was: " + strValue +"\r\n") ;
    		    	
    	 	out.close() ;
    	}catch(IOException exp){
    		System.err.println("ERROR:" + exp.toString());
    	}catch(Exception ex){
    		System.err.println(ex.toString());
    	}
    }
    
    


  • Closed Accounts Posts: 25 dan_pretty_boy


    Hi,

    You have a number of options

    (1) Log4j

    (2) Or used the log method from the ServletContext


    Search http://forums.java.sun.com

    danny


  • Registered Users Posts: 451 ✭✭LeperKing


    Thanks folks problem sorted.

    System.out.println() goes to the tomcat logs, which is all i need.

    LK


Advertisement