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
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Servlet won't write logs

  • 15-04-2005 11:13am
    #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