Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Servlet won't write logs

  • 15-04-2005 12:13PM
    #1
    Registered Users, Registered Users 2 Posts: 452 ✭✭


    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, Registered Users 2 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, Registered Users 2 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, Registered Users 2 Posts: 452 ✭✭LeperKing


    Thanks folks problem sorted.

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

    LK


Advertisement