locked
Logging Application Block - Format TimeStamp RRS feed

  • Question

  • User-608679614 posted

    How can i format the TimeStamp to the pattern i want, default is something like this 4/1/2007 05:40:44 AM. But i want to format it to pattern i want such as 17:40:44. I try to format it at LogEntry level but the TimeStamp type is DateTime, i struggled out many ways to solve it but i failed to. Which entry point can i format ? For i.e. LogEntry point or formatter template level. Please help, many thanks :D

    Sunday, April 1, 2007 3:21 AM

All replies

  • User445179017 posted

    You can use the ToLongTimeString() method of the DateTime to format the time value the way you want it.

    DateTime _now = DateTime.Now;
    Response.Write(_now.ToLongTimeString());

    Thanks

    Sunday, April 1, 2007 7:16 AM
  • User-608679614 posted

    Hi, thanks for the reply, but i guess this is not what i want, what i want is when the Logging to a textfile, the TimeStamp format will become hh:mm:ss rather than the time format determine by the system.

    For example
    LogEntry le = new LogEntry();
    le.TimeStamp =System.DateTime.Now;

    Where TimeStamp only accept DateTime type, when i wanna output in the log file, i can only user the template which is already predefined in the app.config {timestamp} to output the figure, my question is since i cant control when assign the value to the le.TimeStamp, how could i format the output in the app.config. Thanks

     

    Sunday, April 1, 2007 7:46 AM
  • User-608679614 posted
    Hi, anybody have the solution ?? Please help yea and i cant figure it out. Thanks alot :)
    Monday, April 2, 2007 8:55 PM
  • User445179017 posted

    Is LogEntry your custom class?

    Thanks

    Tuesday, April 3, 2007 8:51 AM
  • User-608679614 posted
    Is Microsoft Application Block . Thanks.
    Tuesday, April 3, 2007 8:52 PM