IFlushable.cs 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #region Apache License
  2. //
  3. // Licensed to the Apache Software Foundation (ASF) under one or more
  4. // contributor license agreements. See the NOTICE file distributed with
  5. // this work for additional information regarding copyright ownership.
  6. // The ASF licenses this file to you under the Apache License, Version 2.0
  7. // (the "License"); you may not use this file except in compliance with
  8. // the License. You may obtain a copy of the License at
  9. //
  10. // http://www.apache.org/licenses/LICENSE-2.0
  11. //
  12. // Unless required by applicable law or agreed to in writing, software
  13. // distributed under the License is distributed on an "AS IS" BASIS,
  14. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. // See the License for the specific language governing permissions and
  16. // limitations under the License.
  17. //
  18. #endregion
  19. using System;
  20. namespace log4net.Appender
  21. {
  22. /// <summary>
  23. /// Interface that can be implemented by Appenders that buffer logging data and expose a <see cref="Flush"/> method.
  24. /// </summary>
  25. public interface IFlushable
  26. {
  27. /// <summary>
  28. /// Flushes any buffered log data.
  29. /// </summary>
  30. /// <remarks>
  31. /// Appenders that implement the <see cref="Flush"/> method must do so in a thread-safe manner: it can be called concurrently with
  32. /// the <see cref="log4net.Appender.IAppender.DoAppend"/> method.
  33. /// <para>
  34. /// Typically this is done by locking on the Appender instance, e.g.:
  35. /// <code>
  36. /// <![CDATA[
  37. /// public bool Flush(int millisecondsTimeout)
  38. /// {
  39. /// lock(this)
  40. /// {
  41. /// // Flush buffered logging data
  42. /// ...
  43. /// }
  44. /// }
  45. /// ]]>
  46. /// </code>
  47. /// </para>
  48. /// <para>
  49. /// The <paramref name="millisecondsTimeout"/> parameter is only relevant for appenders that process logging events asynchronously,
  50. /// such as <see cref="RemotingAppender"/>.
  51. /// </para>
  52. /// </remarks>
  53. /// <param name="millisecondsTimeout">The maximum time to wait for logging events to be flushed.</param>
  54. /// <returns><c>True</c> if all logging events were flushed successfully, else <c>false</c>.</returns>
  55. bool Flush(int millisecondsTimeout);
  56. }
  57. }