In the stacktrace property of the ResponseStatus object in a servicestack response, there is a time stamp as follows:
"StackTrace": [GetEmployee: 8/12/2015 9:09:35 PM]
The timestamp, however, is in UTC time. Is it possible for me to configure servicestack to always return the server (or local) time instead of UTC for stacktrace errors?
ServiceStack consistency uses DateTime.UtcNow
for performance and uniformity throughout the code-base. You can't change the hard-coded usage of DateTime.UtcNow
directly but you can override the OnExceptionTypeFilter in your AppHost to modify/decorate the returned ResponseStatus
which will let you replace the existing DateTime to DateTime.Now
with something like:
public override void OnExceptionTypeFilter(
Exception ex, ResponseStatus responseStatus)
{
base.OnExceptionTypeFilter(ex, responseStatus);
var parts = (responseStatus.StackTrace ?? "").SplitOnFirst(']');
if (parts.Length != 2) return;
var requestName = parts[0].Substring(1).SplitOnFirst(':')[0];
responseStatus.StackTrace = "[{0}: {1}]{2}".Fmt(
requestName, DateTime.Now, parts[1]);
}