aspose file tools*
The moose likes Applets and the fly likes How to log in an applet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Applets
Bookmark "How to log in an applet" Watch "How to log in an applet" New topic
Author

How to log in an applet

Angus Comber
Ranch Hand

Joined: Jul 16, 2011
Posts: 90
In a Java application you can log to a file (or the console) but how can you create logging information in an applet?
Nam Ha
Ranch Hand

Joined: Aug 05, 2011
Posts: 50

Angus Comber wrote:In a Java application you can log to a file (or the console) but how can you create logging information in an applet?


Applet has its own console window called Java Plugin Console.

Have a lookt at: Java Plug-in Console


Java Object Creation
Angus Comber
Ranch Hand

Joined: Jul 16, 2011
Posts: 90
Ah ok I have seen that. So System.out.println() goes there?
Nam Ha
Ranch Hand

Joined: Aug 05, 2011
Posts: 50

Angus Comber wrote:Ah ok I have seen that. So System.out.println() goes there?

That's right.
B Alin
Greenhorn

Joined: Jan 17, 2012
Posts: 8
You can use a logging library such as log4j from the apache software foundation.

If you decide to use this, a good idea is to get chainsaw also. The idea is to display the logging messages from log4j in a user-friendly interface as chainsaw.

More pointers :
- for each class use it's own logging object :
class MyClass {
static final private Logger logger = Logger.getInstance(MyClass.class);
[ ... code ... ]
}

- how to configure logger in the "log4j.properties" file for your project :

log4j.rootLogger=TRACE, Chainsaw

log4j.appender.Chainsaw=org.apache.log4j.net.SocketAppender
log4j.appender.Chainsaw.layout=org.apache.log4j.PatternLayout
log4j.appender.Chainsaw.layout.ConversionPattern=%M - %L %n%m
#log4j.appender.Chainsaw.RemoteHost=localhost
log4j.appender.Chainsaw.RemoteHost=192.168.0.26
log4j.appender.Chainsaw.Port=4445
log4j.appender.Chainsaw.LocationInfo=true

Works like a charm
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
It would be very unusual to go to the trouble of setting up log4j in an applet; I wouldn't recommend it.
B Alin
Greenhorn

Joined: Jan 17, 2012
Posts: 8
very unusual ?

funny thing, my co-workers agree it's unusual and at the same time expect me to trace bugs using messages to System.out and/or running the applet step-by-step in debug mode (NetBeans or your choice of an IDE).

unusual ? granted. useful ? very.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: How to log in an applet