logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Maciej Gawinecki ...@bydnet.pl>
Subject serialize hand-crafted appender
Date Wed, 22 Mar 2006 14:38:30 GMT
Hello,

I've prepared ACLAppender which extends non-serializable
AppenderSkeleton. This appender is attached to SystemAgent's logger,
which is <transient> field of the Agent. But during serialization
(standard -- no changes made to writeObject() method) I got

  java.io.NotSerializableException: jacs.core.debug.ACLAppender

I suppose this could be caused by <NON-transient> references to the
appender (the only one I know is reference to the SystemAgent instance
passed by ACLAppender constructor) thus I decided to call
beforeSerialization() method and re-create logger after successful
serialization. 
  
Please see the code below:
---
public class SystemAgent extends Agent {
  protected transient Logger logger;
 
  protected void setup() {
    logger = Logger.getLogger(getLoggerName());
    logger.addAppender(new ACLAppender(this));
  }

  protected void beforeSerialization() {
    Appender appender = logger.getAppender(ACLAppender.ACL_APPENDER_NAME);
    appender.close();
    logger.removeAllAppenders();
    appender = null;
    LogManager.shutdown();
    logger = null;
  }
}
---

Unfortunately there is still the exception. Do you know why?
I would be greatful for any help,

Regards,

Maciej


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


Mime
View raw message