You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by "Rhodes, Michael" <Rh...@diebold.com> on 2001/10/15 13:52:10 UTC

Applet logging to remote SocketServer

I'm having difficulty getting an applet to log to a remote socket server.  My configuration is failing.  It appears that a socket connection *does* get opened to the server.  Any advice on this?  Included below is:

Netscape Java Console output
SimpleSocketServer output
Applet source
HTML source

The output shown was collected after pressing the HTML button 8 times.

TIA.

Michael E. Rhodes 
Diebold, Incorporated

Netscape Java Console output ==========================================
Netscape Communications Corporation -- Java 1.1.5 
Type '?' for options. 
Symantec Java! ByteCode Compiler Version 210.065
Copyright (C) 1996-97 Symantec Corporation
log4j: Could not read system property "log4j.configDebug". 
java.lang.NullPointerException
   at org.apache.log4j.BasicConfigurator.configure(Compiled Code)
   at com.diebold.util.Log.initLogging(Compiled Code)
   at com.diebold.util.Log.init(Compiled Code)
 * at netscape.applet.DerivedAppletFrame$InitAppletEvent.dispatch(Compiled Code)
   at java.awt.EventDispatchThread$EventPump.dispatchEvents(Compiled Code)
   at java.awt.EventDispatchThread.run(Compiled Code)
   at netscape.applet.DerivedAppletFrame$AppletEventDispatchThread.run(Compiled Code) 
message = "HI" 
log4j:ERROR No appenders could be found for category (com.diebold.util.Log). log4j:ERROR Please initialize the log4j system properly. 
message = "HI"
message = "HI" 
message = "HI" 
message = "HI" 
message = "HI" 
message = "HI" 
message = "HI" 


SimpleSocketServer output =============================================
22:36:51 INFO  [main] impleSocketServer               - Listening on port 9009
22:36:51 INFO  [main] impleSocketServer               - Waiting to accept a new client.
22:38:39 INFO  [main] impleSocketServer               - Connected to client at localhost/127.0.0.1
22:38:39 INFO  [main] impleSocketServer               - Starting new socket node.
22:38:39 INFO  [main] impleSocketServer               - Waiting to accept a new client.
22:41:22 INFO  [Thread-0] net.SocketNode                  - Caught java.io.EOFException closing conneciton.


Applet source =========================================================
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
import org.apache.log4j.*;
import org.apache.log4j.net.*;

public class Log extends Applet {

public void info(String message) {
	System.out.println("message = \"" + message + "\"");
	Category cat = Category.getInstance(Log.class.getName());
	cat.info(message);
}

public void init() {
	String host = getParameter("HOST");
	int port = Integer.decode(getParameter("PORT")).intValue();
	initLogging(host,port);
}

public void initLogging(String host, int port) {
	BasicConfigurator.configure(new SocketAppender(host,port));
}

public void paint(Graphics g) {
	super.paint(g);
}
}


HTML source ===========================================================
<HTML>
<HEAD>
  <TITLE>Log</TITLE>
</HEAD>
<BODY> 
<script>
  function doLog() {
    document.logger.info("HI");
  }
</script>
<H1>Log</H1>
<APPLET MAYSCRIPT CODE=com.diebold.util.Log.class ARCHIVE=Log.jar NAME="logger" WIDTH=150 HEIGHT=25>
  <param name=HOST value="localhost">
  <param name=PORT value=9009>
</APPLET>
<form name=form1>
  <input onclick="Javascript:doLog()" type="button"  value="doLog">
</form>
</BODY>
</HTML>


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: log4j-user-help@jakarta.apache.org