How to display date and time, at the moment I only see date without timestamp (using ServiceStack 5.5.1):
AppHost:
using Funq;
using ServiceStack;
using ServiceStack.Admin;
using ServiceStack.IO;
using ServiceStack.VirtualPath;
using System;
using System.Collections.Generic;
namespace SelfHost1
{
//VS.NET Template Info: https://servicestack.net/vs-templates/EmptySelfHost
public class AppHost : AppSelfHostBase
{
/// <summary>
/// Base constructor requires a Name and Assembly where web service implementation is located
/// </summary>
public AppHost()
: base("RequestViewer", typeof(DaveCsvRequestLoggerQueryDataServices).Assembly)
{
}
/// <summary>
/// Application specific configuration
/// This method should initialize any IoC resources utilized by your web service classes.
/// </summary>
public override void Configure(Container container)
{
Plugins.Add(new AdminFeature());
Plugins.Add(new AutoQueryFeature { MaxLimit = 100 });
Plugins.Add(new AutoQueryDataFeature { MaxLimit = 100 });
}
public override List<IVirtualPathProvider> GetVirtualFileSources()
{
var existingProviders = base.GetVirtualFileSources();
existingProviders.Add(new FileSystemMapping("requestlogs", @"C:\Users\mob\Documents\Visual Studio 2017\Projects\SelfHost1\SelfHost1\SelfHost1\requestlogs"));
return existingProviders;
}
}
public class DaveCsvRequestLoggerQueryDataServices : Service
{
public IAutoQueryData AutoQuery { get; set; }
public object Any(QueryErrorLogs query)
{
var date = query.Date.GetValueOrDefault(DateTime.UtcNow);
//var logSuffix = query.ViewErrors ? "-errors" : "";
var logSuffix = "-errors";
var file = new FileSystemVirtualFiles(HostContext.Config.WebHostPhysicalPath);
//var file = new FileSystemMapping("requestlogs", @"C:\Users\mob\Documents\Visual Studio 2017\Projects\SelfHost1\SelfHost1\SelfHost1\requestlogs"); //new FileSystemVirtualFiles("~/".MapProjectPath() + "requestlogs");
var csvLogsFile = file.GetFile(
"requestlogs/{0}-{1}/{0}-{1}-{2}{3}.csv".Fmt(
date.Year.ToString("0000"),
date.Month.ToString("00"),
date.Day.ToString("00"),
logSuffix));
if (csvLogsFile == null)
throw HttpError.NotFound("No logs found on " + date.ToShortDateString());
var logs = csvLogsFile.ReadAllText().FromCsv<List<RequestLogEntry>>();
var q = AutoQuery.CreateQuery(query, Request,
db: new MemoryDataSource<RequestLogEntry>(logs, query, Request));
return AutoQuery.Execute(query, q);
}
public object Any(TodayErrorLogs request) => Any(new QueryErrorLogs { Date = DateTime.UtcNow, ViewErrors = true });
public object Any(YesterdayErrorLogs request) => Any(new QueryErrorLogs { Date = DateTime.UtcNow.AddDays(-1), ViewErrors = true });
}
[Route("/query/requestlogs")]
[Route("/query/requestlogs/{Date}")]
public class QueryErrorLogs : QueryData<RequestLogEntry>
{
public DateTime? Date { get; set; }
public bool ViewErrors { get; set; }
}
[Route("/logs/today/errors")]
public class TodayErrorLogs : QueryData<RequestLogEntry> { }
[Route("/logs/yesterday/errors")]
public class YesterdayErrorLogs : QueryData<RequestLogEntry> { }
}
CSV File:
Id,DateTime,StatusCode,StatusDescription,HttpMethod,AbsoluteUri,PathInfo,RequestBody,RequestDto,UserAuthId,SessionId,IpAddress,ForwardedFor,Referer,Headers,FormData,Items,Session,ResponseDto,ErrorResponse,ExceptionSource,ExceptionData,RequestDuration,Meta
8,2019-04-26T13:37:08.2916035Z,404,NotFound,GET,http://127.0.0.1:8088/logs/today/errors.json?include=Total&jsconfig=DateHandler%3AISO8601DateOnly%2CTimeSpanHandler%3AStandardFormat,/logs/today/errors.json,,,,bVM1gyE3bPQHEmdqQUR2,127.0.0.1,,http://127.0.0.1:8088/ss_admin/autoquery/TodayErrorLogs,"{Connection:keep-alive,Content-Type:application/json,Accept:*/*,Accept-Encoding:""gzip,deflate,br"",Accept-Language:""de-DE,de;q=0.9,en-US;q=0.8,en;q=0.7"",Cookie:ss-pid=MiLsjvhmJK8PgTkAOsbP; ss-id=bVM1gyE3bPQHEmdqQUR2,Host:""127.0.0.1:8088"",Referer:""http://127.0.0.1:8088/ss_admin/autoquery/TodayErrorLogs"",User-Agent:""Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.87 Safari/537.36""}","{}","{__route:ServiceStack.Host.RestPath,_requestDurationStopwatch:System.Diagnostics.Stopwatch}",,,"{errorCode:NotFound,message:No logs found on 26.04.2019,stackTrace:""[TodayErrorLogs: 26.04.2019 13:37:08]:
[REQUEST: {include:Total}]
ServiceStack.HttpError: No logs found on 26.04.2019
bei SelfHost1.ServiceInterface.DaveCsvRequestLoggerQueryDataServices.Any(QueryRequestLogs query) in C:\Users\mob\Documents\Visual Studio 2017\Projects\SelfHost1\SelfHost1\SelfHost1.ServiceInterface\MyServices.cs:Zeile 32.
bei SelfHost1.ServiceInterface.DaveCsvRequestLoggerQueryDataServices.Any(TodayErrorLogs request) in C:\Users\mob\Documents\Visual Studio 2017\Projects\SelfHost1\SelfHost1\SelfHost1.ServiceInterface\MyServices.cs:Zeile 44.
bei lambda_method(Closure , Object , Object )
bei ServiceStack.Host.ServiceRunner`1.<ExecuteAsync>d__15.MoveNext()"",errors:[]}",,,PT0S,
9,2019-04-26T13:37:10.467384Z,404,NotFound,GET,http://127.0.0.1:8088/logs/yesterday.json?include=Total&jsconfig=DateHandler%3AISO8601DateOnly%2CTimeSpanHandler%3AStandardFormat,/logs/yesterday.json,,,,bVM1gyE3bPQHEmdqQUR2,127.0.0.1,,http://127.0.0.1:8088/ss_admin/autoquery/YesterdayLogs,"{Connection:keep-alive,Content-Type:application/json,Accept:*/*,Accept-Encoding:""gzip,deflate,br"",Accept-Language:""de-DE,de;q=0.9,en-US;q=0.8,en;q=0.7"",Cookie:ss-pid=MiLsjvhmJK8PgTkAOsbP; ss-id=bVM1gyE3bPQHEmdqQUR2,Host:""127.0.0.1:8088"",Referer:""http://127.0.0.1:8088/ss_admin/autoquery/YesterdayLogs"",User-Agent:""Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.87 Safari/537.36""}","{}","{__route:ServiceStack.Host.RestPath,_requestDurationStopwatch:System.Diagnostics.Stopwatch}",,,"{errorCode:NotFound,message:No logs found on 25.04.2019,stackTrace:""[YesterdayLogs: 26.04.2019 13:37:10]:
[REQUEST: {include:Total}]
ServiceStack.HttpError: No logs found on 25.04.2019
bei SelfHost1.ServiceInterface.DaveCsvRequestLoggerQueryDataServices.Any(QueryRequestLogs query) in C:\Users\mob\Documents\Visual Studio 2017\Projects\SelfHost1\SelfHost1\SelfHost1.ServiceInterface\MyServices.cs:Zeile 32.
bei SelfHost1.ServiceInterface.DaveCsvRequestLoggerQueryDataServices.Any(YesterdayLogs request) in C:\Users\mob\Documents\Visual Studio 2017\Projects\SelfHost1\SelfHost1\SelfHost1.ServiceInterface\MyServices.cs:Zeile 46.
bei lambda_method(Closure , Object , Object )
bei ServiceStack.Host.ServiceRunner`1.<ExecuteAsync>d__15.MoveNext()"",errors:[]}",,,PT0S,
10,2019-04-26T13:37:11.8670524Z,404,NotFound,GET,http://127.0.0.1:8088/logs/yesterday/errors.json?include=Total&jsconfig=DateHandler%3AISO8601DateOnly%2CTimeSpanHandler%3AStandardFormat,/logs/yesterday/errors.json,,,,bVM1gyE3bPQHEmdqQUR2,127.0.0.1,,http://127.0.0.1:8088/ss_admin/autoquery/YesterdayErrorLogs,"{Connection:keep-alive,Content-Type:application/json,Accept:*/*,Accept-Encoding:""gzip,deflate,br"",Accept-Language:""de-DE,de;q=0.9,en-US;q=0.8,en;q=0.7"",Cookie:ss-pid=MiLsjvhmJK8PgTkAOsbP; ss-id=bVM1gyE3bPQHEmdqQUR2,Host:""127.0.0.1:8088"",Referer:""http://127.0.0.1:8088/ss_admin/autoquery/YesterdayErrorLogs"",User-Agent:""Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.87 Safari/537.36""}","{}","{__route:ServiceStack.Host.RestPath,_requestDurationStopwatch:System.Diagnostics.Stopwatch}",,,"{errorCode:NotFound,message:No logs found on 25.04.2019,stackTrace:""[YesterdayErrorLogs: 26.04.2019 13:37:11]:
[REQUEST: {include:Total}]
ServiceStack.HttpError: No logs found on 25.04.2019
bei SelfHost1.ServiceInterface.DaveCsvRequestLoggerQueryDataServices.Any(QueryRequestLogs query) in C:\Users\mob\Documents\Visual Studio 2017\Projects\SelfHost1\SelfHost1\SelfHost1.ServiceInterface\MyServices.cs:Zeile 32.
bei SelfHost1.ServiceInterface.DaveCsvRequestLoggerQueryDataServices.Any(YesterdayErrorLogs request) in C:\Users\mob\Documents\Visual Studio 2017\Projects\SelfHost1\SelfHost1\SelfHost1.ServiceInterface\MyServices.cs:Zeile 48.
bei lambda_method(Closure , Object , Object )
bei ServiceStack.Host.ServiceRunner`1.<ExecuteAsync>d__15.MoveNext()"",errors:[]}",,,PT0S,
11,2019-04-26T13:37:13.7880738Z,404,NotFound,GET,http://127.0.0.1:8088/logs/yesterday.json?include=Total&jsconfig=DateHandler%3AISO8601DateOnly%2CTimeSpanHandler%3AStandardFormat,/logs/yesterday.json,,,,bVM1gyE3bPQHEmdqQUR2,127.0.0.1,,http://127.0.0.1:8088/ss_admin/autoquery/YesterdayLogs,"{Connection:keep-alive,Content-Type:application/json,Accept:*/*,Accept-Encoding:""gzip,deflate,br"",Accept-Language:""de-DE,de;q=0.9,en-US;q=0.8,en;q=0.7"",Cookie:ss-pid=MiLsjvhmJK8PgTkAOsbP; ss-id=bVM1gyE3bPQHEmdqQUR2,Host:""127.0.0.1:8088"",Referer:""http://127.0.0.1:8088/ss_admin/autoquery/YesterdayLogs"",User-Agent:""Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.87 Safari/537.36""}","{}","{__route:ServiceStack.Host.RestPath,_requestDurationStopwatch:System.Diagnostics.Stopwatch}",,,"{errorCode:NotFound,message:No logs found on 25.04.2019,stackTrace:""[YesterdayLogs: 26.04.2019 13:37:13]:
[REQUEST: {include:Total}]
ServiceStack.HttpError: No logs found on 25.04.2019
bei SelfHost1.ServiceInterface.DaveCsvRequestLoggerQueryDataServices.Any(QueryRequestLogs query) in C:\Users\mob\Documents\Visual Studio 2017\Projects\SelfHost1\SelfHost1\SelfHost1.ServiceInterface\MyServices.cs:Zeile 32.
bei SelfHost1.ServiceInterface.DaveCsvRequestLoggerQueryDataServices.Any(YesterdayLogs request) in C:\Users\mob\Documents\Visual Studio 2017\Projects\SelfHost1\SelfHost1\SelfHost1.ServiceInterface\MyServices.cs:Zeile 46.
bei lambda_method(Closure , Object , Object )
bei ServiceStack.Host.ServiceRunner`1.<ExecuteAsync>d__15.MoveNext()"",errors:[]}",,,PT0S,
12,2019-04-26T13:37:14.6710576Z,404,NotFound,GET,http://127.0.0.1:8088/logs/today.json?include=Total&jsconfig=DateHandler%3AISO8601DateOnly%2CTimeSpanHandler%3AStandardFormat,/logs/today.json,,,,bVM1gyE3bPQHEmdqQUR2,127.0.0.1,,http://127.0.0.1:8088/ss_admin/autoquery/TodayLogs,"{Connection:keep-alive,Content-Type:application/json,Accept:*/*,Accept-Encoding:""gzip,deflate,br"",Accept-Language:""de-DE,de;q=0.9,en-US;q=0.8,en;q=0.7"",Cookie:ss-pid=MiLsjvhmJK8PgTkAOsbP; ss-id=bVM1gyE3bPQHEmdqQUR2,Host:""127.0.0.1:8088"",Referer:""http://127.0.0.1:8088/ss_admin/autoquery/TodayLogs"",User-Agent:""Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.87 Safari/537.36""}","{}","{__route:ServiceStack.Host.RestPath,_requestDurationStopwatch:System.Diagnostics.Stopwatch}",,,"{errorCode:NotFound,message:No logs found on 26.04.2019,stackTrace:""[TodayLogs: 26.04.2019 13:37:14]:
[REQUEST: {include:Total}]
ServiceStack.HttpError: No logs found on 26.04.2019
bei SelfHost1.ServiceInterface.DaveCsvRequestLoggerQueryDataServices.Any(QueryRequestLogs query) in C:\Users\mob\Documents\Visual Studio 2017\Projects\SelfHost1\SelfHost1\SelfHost1.ServiceInterface\MyServices.cs:Zeile 32.
bei SelfHost1.ServiceInterface.DaveCsvRequestLoggerQueryDataServices.Any(TodayLogs request) in C:\Users\mob\Documents\Visual Studio 2017\Projects\SelfHost1\SelfHost1\SelfHost1.ServiceInterface\MyServices.cs:Zeile 42.
bei lambda_method(Closure , Object , Object )
bei ServiceStack.Host.ServiceRunner`1.<ExecuteAsync>d__15.MoveNext()"",errors:[]}",,,PT0S,
13,2019-04-26T13:37:14.8380572Z,500,NullReferenceException,GET,http://127.0.0.1:8088/logs/today/errors.json?include=Total&jsconfig=DateHandler%3AISO8601DateOnly%2CTimeSpanHandler%3AStandardFormat,/logs/today/errors.json,,,,bVM1gyE3bPQHEmdqQUR2,127.0.0.1,,http://127.0.0.1:8088/ss_admin/autoquery/TodayErrorLogs,"{Connection:keep-alive,Content-Type:application/json,Accept:*/*,Accept-Encoding:""gzip,deflate,br"",Accept-Language:""de-DE,de;q=0.9,en-US;q=0.8,en;q=0.7"",Cookie:ss-pid=MiLsjvhmJK8PgTkAOsbP; ss-id=bVM1gyE3bPQHEmdqQUR2,Host:""127.0.0.1:8088"",Referer:""http://127.0.0.1:8088/ss_admin/autoquery/TodayErrorLogs"",User-Agent:""Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.87 Safari/537.36""}","{}","{__route:ServiceStack.Host.RestPath,_requestDurationStopwatch:System.Diagnostics.Stopwatch}",,,"{errorCode:NullReferenceException,message:Der Objektverweis wurde nicht auf eine Objektinstanz festgelegt.,stackTrace:""[TodayErrorLogs: 26.04.2019 13:37:14]:
[REQUEST: {include:Total}]
System.NullReferenceException: Der Objektverweis wurde nicht auf eine Objektinstanz festgelegt.
bei ServiceStack.AutoQueryDataExtensions.CreateQuery[From](IAutoQueryData autoQuery, IQueryData`1 model, IRequest request, IQueryDataSource db)
bei SelfHost1.ServiceInterface.DaveCsvRequestLoggerQueryDataServices.Any(QueryRequestLogs query) in C:\Users\mob\Documents\Visual Studio 2017\Projects\SelfHost1\SelfHost1\SelfHost1.ServiceInterface\MyServices.cs:Zeile 36.
bei SelfHost1.ServiceInterface.DaveCsvRequestLoggerQueryDataServices.Any(TodayErrorLogs request) in C:\Users\mob\Documents\Visual Studio 2017\Projects\SelfHost1\SelfHost1\SelfHost1.ServiceInterface\MyServices.cs:Zeile 44.
bei lambda_method(Closure , Object , Object )
bei ServiceStack.Host.ServiceRunner`1.<ExecuteAsync>d__15.MoveNext()"",errors:[]}",,,PT0S,
14,2019-04-26T13:37:14.9590615Z,404,NotFound,GET,http://127.0.0.1:8088/logs/today.json?include=Total&jsconfig=DateHandler%3AISO8601DateOnly%2CTimeSpanHandler%3AStandardFormat,/logs/today.json,,,,bVM1gyE3bPQHEmdqQUR2,127.0.0.1,,http://127.0.0.1:8088/ss_admin/autoquery/TodayLogs,"{Connection:keep-alive,Content-Type:application/json,Accept:*/*,Accept-Encoding:""gzip,deflate,br"",Accept-Language:""de-DE,de;q=0.9,en-US;q=0.8,en;q=0.7"",Cookie:ss-pid=MiLsjvhmJK8PgTkAOsbP; ss-id=bVM1gyE3bPQHEmdqQUR2,Host:""127.0.0.1:8088"",Referer:""http://127.0.0.1:8088/ss_admin/autoquery/TodayLogs"",User-Agent:""Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.87 Safari/537.36""}","{}","{__route:ServiceStack.Host.RestPath,_requestDurationStopwatch:System.Diagnostics.Stopwatch}",,,"{errorCode:NotFound,message:No logs found on 26.04.2019,stackTrace:""[TodayLogs: 26.04.2019 13:37:14]:
[REQUEST: {include:Total}]
ServiceStack.HttpError: No logs found on 26.04.2019
bei SelfHost1.ServiceInterface.DaveCsvRequestLoggerQueryDataServices.Any(QueryRequestLogs query) in C:\Users\mob\Documents\Visual Studio 2017\Projects\SelfHost1\SelfHost1\SelfHost1.ServiceInterface\MyServices.cs:Zeile 32.
bei SelfHost1.ServiceInterface.DaveCsvRequestLoggerQueryDataServices.Any(TodayLogs request) in C:\Users\mob\Documents\Visual Studio 2017\Projects\SelfHost1\SelfHost1\SelfHost1.ServiceInterface\MyServices.cs:Zeile 42.
bei lambda_method(Closure , Object , Object )
bei ServiceStack.Host.ServiceRunner`1.<ExecuteAsync>d__15.MoveNext()"",errors:[]}",,,PT0S,
15,2019-04-26T13:37:16.3544388Z,404,NotFound,GET,http://127.0.0.1:8088/query/requestlogs.json?include=Total&jsconfig=DateHandler%3AISO8601DateOnly%2CTimeSpanHandler%3AStandardFormat,/query/requestlogs.json,,,,bVM1gyE3bPQHEmdqQUR2,127.0.0.1,,http://127.0.0.1:8088/ss_admin/autoquery/QueryRequestLogs,"{Connection:keep-alive,Content-Type:application/json,Accept:*/*,Accept-Encoding:""gzip,deflate,br"",Accept-Language:""de-DE,de;q=0.9,en-US;q=0.8,en;q=0.7"",Cookie:ss-pid=MiLsjvhmJK8PgTkAOsbP; ss-id=bVM1gyE3bPQHEmdqQUR2,Host:""127.0.0.1:8088"",Referer:""http://127.0.0.1:8088/ss_admin/autoquery/QueryRequestLogs"",User-Agent:""Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.87 Safari/537.36""}","{}","{__route:ServiceStack.Host.RestPath,_requestDurationStopwatch:System.Diagnostics.Stopwatch}",,,"{errorCode:NotFound,message:No logs found on 26.04.2019,stackTrace:""[QueryRequestLogs: 26.04.2019 13:37:16]:
[REQUEST: {viewErrors:False,include:Total}]
ServiceStack.HttpError: No logs found on 26.04.2019
bei SelfHost1.ServiceInterface.DaveCsvRequestLoggerQueryDataServices.Any(QueryRequestLogs query) in C:\Users\mob\Documents\Visual Studio 2017\Projects\SelfHost1\SelfHost1\SelfHost1.ServiceInterface\MyServices.cs:Zeile 32.
bei lambda_method(Closure , Object , Object )
bei ServiceStack.Host.ServiceRunner`1.<ExecuteAsync>d__15.MoveNext()"",errors:[]}",,,PT0S,
16,2019-04-26T13:37:20.5075304Z,404,NotFound,GET,http://127.0.0.1:8088/logs/today.json?include=Total&jsconfig=DateHandler%3AISO8601DateOnly%2CTimeSpanHandler%3AStandardFormat,/logs/today.json,,,,bVM1gyE3bPQHEmdqQUR2,127.0.0.1,,http://127.0.0.1:8088/ss_admin/autoquery/TodayLogs,"{Connection:keep-alive,Content-Type:application/json,Accept:*/*,Accept-Encoding:""gzip,deflate,br"",Accept-Language:""de-DE,de;q=0.9,en-US;q=0.8,en;q=0.7"",Cookie:ss-pid=MiLsjvhmJK8PgTkAOsbP; ss-id=bVM1gyE3bPQHEmdqQUR2,Host:""127.0.0.1:8088"",Referer:""http://127.0.0.1:8088/ss_admin/autoquery/TodayLogs"",User-Agent:""Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.87 Safari/537.36""}","{}","{__route:ServiceStack.Host.RestPath,_requestDurationStopwatch:System.Diagnostics.Stopwatch}",,,"{errorCode:NotFound,message:No logs found on 26.04.2019,stackTrace:""[TodayLogs: 26.04.2019 13:37:20]:
[REQUEST: {include:Total}]
ServiceStack.HttpError: No logs found on 26.04.2019
bei SelfHost1.ServiceInterface.DaveCsvRequestLoggerQueryDataServices.Any(QueryRequestLogs query) in C:\Users\mob\Documents\Visual Studio 2017\Projects\SelfHost1\SelfHost1\SelfHost1.ServiceInterface\MyServices.cs:Zeile 32.
bei SelfHost1.ServiceInterface.DaveCsvRequestLoggerQueryDataServices.Any(TodayLogs request) in C:\Users\mob\Documents\Visual Studio 2017\Projects\SelfHost1\SelfHost1\SelfHost1.ServiceInterface\MyServices.cs:Zeile 42.
bei lambda_method(Closure , Object , Object )
bei ServiceStack.Host.ServiceRunner`1.<ExecuteAsync>d__15.MoveNext()"",errors:[]}",,,PT0S,