public void Attach(ILogWriter newLogWriter) { if (newLogWriter == null) { throw new ArgumentNullException("newLogWriter"); } if (newLogWriter == this.WrappedLogWriter) { return; } ILogWriter prevLogWriter = this.WrappedLogWriter; Exception detachException = null; if (this.WrappedLogWriter != null) { try { prevLogWriter.Detach(); } catch (Exception ex) { detachException = ex; } this.WrappedLogWriter.ServerWriteLine( string.Format("Log writer \"{0}\" is being detached.", this.LogWriterName), TraceLevel.Verbose); } this.WrappedLogWriter = newLogWriter; this.WrappedLogWriter.ServerWriteLine( string.Format("Log writer \"{0}\" has been attached.", this.LogWriterName), TraceLevel.Verbose); if (detachException != null) { this.ServerWriteLine( string.Format("Log writer \"{0}\" had thrown an unexpected exception:\n{1}", prevLogWriter.Name, detachException), TraceLevel.Error); } }