Jeff,

Have you considered using the basic techniques already offered by the log4j framework? For instance, you could configure log4j differently when running as an applet.

In the init() method of your appplet, you could write:

  Logger timestampLogger = Logger.getLogger("TimeStamp");
  timestampLogger.setLevel(Level.OFF);

You could even disable logging altogether

  Logger root = Logger.getRootLogger();
  root.setLevel(Level.OFF);

I hope this helps,

At 11:32 PM 2/20/2006, Jeff Drew wrote:
I'm converting my desktop application to an applet.  Due to browser
security, I can't read or write local files so I can neither use .properties
nor write logs.  My dilemma is rooted in reusable classes.  My desktop
application(now applet) uses some classes, such as a timeStamp class, that
are also used in my server.  I'd prefer to retain that class's logging
capability when it is running in the server, but disable the logging when
running in the applet.

I see 3 alternatives:
1. move the logger instantiation to the constructor, then pass the
constructor a newly created boolean indicating whether it's running as an
applet.
2. subclass Logger, then have the subclass check some global boolean
indicating whether it's running as an applet
3. remove logging from the reused classes altogether

I don't like any of these alternatives and wondered if there is another,
more appealing alternative.  Here's a simple example that illustrates my
problem.

Thanks

Jeff

public class TimeStamp implements Serializable {

// the following line will cause a security exception
    static Logger                         cat              =
Logger.getLogger( "TimeStamp" );

   public TimeStamp( long milliSeconds ) {

   }
}

--
Ceki Gülcü


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to