RawUtcTimeStampLayout.cs 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. using System.Text;
  21. using log4net.Core;
  22. using log4net.Util;
  23. namespace log4net.Layout
  24. {
  25. /// <summary>
  26. /// Extract the date from the <see cref="LoggingEvent"/>
  27. /// </summary>
  28. /// <remarks>
  29. /// <para>
  30. /// Extract the date from the <see cref="LoggingEvent"/>
  31. /// </para>
  32. /// </remarks>
  33. /// <author>Nicko Cadell</author>
  34. /// <author>Gert Driesen</author>
  35. public class RawUtcTimeStampLayout : IRawLayout
  36. {
  37. #region Constructors
  38. /// <summary>
  39. /// Constructs a RawUtcTimeStampLayout
  40. /// </summary>
  41. public RawUtcTimeStampLayout()
  42. {
  43. }
  44. #endregion
  45. #region Implementation of IRawLayout
  46. /// <summary>
  47. /// Gets the <see cref="LoggingEvent.TimeStamp"/> as a <see cref="DateTime"/>.
  48. /// </summary>
  49. /// <param name="loggingEvent">The event to format</param>
  50. /// <returns>returns the time stamp</returns>
  51. /// <remarks>
  52. /// <para>
  53. /// Gets the <see cref="LoggingEvent.TimeStamp"/> as a <see cref="DateTime"/>.
  54. /// </para>
  55. /// <para>
  56. /// The time stamp is in universal time. To format the time stamp
  57. /// in local time use <see cref="RawTimeStampLayout"/>.
  58. /// </para>
  59. /// </remarks>
  60. public virtual object Format(LoggingEvent loggingEvent)
  61. {
  62. return loggingEvent.TimeStampUtc;
  63. }
  64. #endregion
  65. }
  66. }