ServiceStack CsvRequestLogger无法读取最后一个条目异常

时间:2017-04-20 12:53:25

标签: c# servicestack nlog

在配置AppHost期间,始终会从ServiceStack.CsvRequestLogger.ReadLastEntry抛出异常。我是想过早构建NLogFactory还是我的命令错误?

2017-04-20 08:42:46.0185 INFO  Api.AppHost.Configure  Starting up...  
2017-04-20 08:42:46.0185 DEBUG Api.AppHost.Configure  Adding plugins  
2017-04-20 08:42:46.0865 ERROR ServiceStack.CsvRequestLogger.ReadLastEntry  Could not read last entry from 'ServiceStack.Logging.NLogger.NLogLogger'  System.FormatException: Input string was not in a correct format.
   at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)
   at System.Number.ParseInt64(String value, NumberStyles options, NumberFormatInfo numfmt)
   at ServiceStack.Text.Common.DeserializeBuiltin`1.<>c.<GetParseFn>b__4_7(String value)
   at ServiceStack.Text.CsvReader`1.Read(List`1 rows)
   at ServiceStack.Text.CsvReader`1.ReadRow(String value)
   at ServiceStack.Text.CsvSerializer`1.ReadSelf(String value)
   at ServiceStack.Text.CsvSerializer`1.ReadObject(String value)
   at ServiceStack.Text.CsvSerializer.DeserializeFromString[T](String text)
   at ServiceStack.CsvRequestLogger.ReadLastEntry(String logFile)

我的Configure方法如下所示:

    public override void Configure(Container container)
    {
        #region Add Plugins
        LogManager.LogFactory = new NLogFactory();
        var log = LogManager.GetLogger(typeof(AppHost));
        log.Info("Starting up...");
        log.Debug("Adding plugins");

        // Init some other plugins here

        Plugins.Add(new RequestLogsFeature
        {
            RequestLogger = new CsvRequestLogger(
                files: new FileSystemVirtualPathProvider(this, Config.WebHostPhysicalPath),
                requestLogsPattern: "requestlogs/{year}-{month}/{year}-{month}-{day}.csv",
                errorLogsPattern: "requestlogs/{year}-{month}/{year}-{month}-{day}-errors.csv",
                appendEvery: TimeSpan.FromSeconds(5)

            ),
            RequiredRoles = new[] { "Admin" }
        });

        // Register connection strings and interfaces
    }

编辑:这是请求日志CSV的最后几行。请注意,在第一个条目和第二个条目之间,应用程序池已被回收。

16,2017-04-19T20:16:01.8207496Z,500,FileLoadException,POST,https://SERVER/API/sms,/sms,,"{To:[5555555555],Body:Test from API}",1,wiw9HsIvCPSF5EFr7a8d,10.211.112.29,,https://SERVER/API/swagger-ui/,"{Connection:keep-alive,Content-Length:36,Content-Type:application/x-www-form-urlencoded,Accept:application/json,Accept-Encoding:""gzip, deflate, br"",Accept-Language:""en-US,en;q=0.8"",Authorization:Bearer v_-3Y_iCe2wBU1gFbYuBKqUOt8E2yiQ6,Cookie:ss-id=wiw9HsIvCPSF5EFr7a8d; ss-pid=EZ09UDOpQBGzUGuhjRUw; ss-opt=temp; X-UAId=1,Host:SERVER,Referer:""https://SERVER/API/swagger-ui/"",User-Agent:""Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.68 Safari/537.36"",Origin:""https://SERVER"",DNT:1}","{To:5555555555,Body:Test from API}","{"":mini-profiler:"":""https://SERVER:443/API/sms/ (634.2 ms)"",AspSessionIDManagerInitializeRequestCalled:True,__route:ServiceStack.Host.RestPath,__haspreauth:True,__apikey:ServiceStack.Auth.ApiKey,__session:ServiceStack.AuthUserSession,_requestDurationStopwatch:System.Diagnostics.Stopwatch}",,,"{ResponseStatus:{ErrorCode:FileLoadException,Message:""Could not load file or assembly 'Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)"",StackTrace:""[SendTextMessage: 4/19/2017 8:16:01 PM]:
[REQUEST: {To:[5555555555],Body:Test from API}]
System.IO.FileLoadException: Could not load file or assembly 'Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
File name: 'Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'
   at Twilio.Rest.Api.V2010.Account.MessageResource.FromJson(String json)
   at Twilio.Rest.Api.V2010.Account.MessageResource.Create(PhoneNumber to, String pathAccountSid, PhoneNumber from, String messagingServiceSid, String body, List`1 mediaUrl, Uri statusCallback, String applicationSid, Nullable`1 maxPrice, Nullable`1 provideFeedback, Nullable`1 validityPeriod, ITwilioRestClient client)
   at Api.Core.Data.Repository.Wrapper.SmsClientWrapper.SendMessage(String to, String body) in D:\TFS\Core\Api\Dev\Api\Api.Core\Data\Repository\Wrapper\SmsClientWrapper.cs:line 25
   at Api.Core.Data.Repository.MessageRepository.SendTextMessage(SendTextMessage request) in D:\TFS\Core\Api\Dev\Api\Api.Core\Data\Repository\MessageRepository.cs:line 144
   at Api.Core.MessageService.Post(SendTextMessage request) in D:\TFS\Core\Api\Dev\Api\Api.Core\Service\MessageService.cs:line 36
   at ServiceStack.Host.ServiceRunner`1.Execute(IRequest request, Object instance, TRequest requestDto)

WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].
"",Errors:[]}}",Twilio,{},PT0.6286441S
    1,2017-04-19T20:17:13.0268695Z,200,OK,GET,https://SERVER/API/resources,/resources,,{},1,wiw9HsIvCPSF5EFr7a8d,10.211.112.29,,https://SERVER/API/swagger-ui/,"{Connection:keep-alive,Accept:""application/json;charset=utf-8,*/*"",Accept-Encoding:""gzip, deflate, sdch, br"",Accept-Language:""en-US,en;q=0.8"",Authorization:Bearer v_-3Y_iCe2wBU1gFbYuBKqUOt8E2yiQ6,Cookie:ss-id=wiw9HsIvCPSF5EFr7a8d; ss-pid=EZ09UDOpQBGzUGuhjRUw; ss-opt=temp; X-UAId=1,Host:SERVER,Referer:""https://SERVER/API/swagger-ui/"",User-Agent:""Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.68 Safari/537.36"",DNT:1}",{},"{"":mini-profiler:"":""https://SERVER:443/API/resources (82.4 ms)"",AspSessionIDManagerInitializeRequestCalled:True,__route:ServiceStack.Host.RestPath,_requestDurationStopwatch:System.Diagnostics.Stopwatch}",,,,,,PT0.0194668S
2,2017-04-19T20:17:13.1338802Z,200,OK,GET,https://SERVER/API/resource/memberaccounts,/resource/memberaccounts,,{name:memberaccounts},1,wiw9HsIvCPSF5EFr7a8d,10.211.112.29,,https://SERVER/API/swagger-ui/,"{Connection:keep-alive,Accept:""application/json;charset=utf-8,*/*"",Accept-Encoding:""gzip, deflate, sdch, br"",Accept-Language:""en-US,en;q=0.8"",Authorization:Bearer v_-3Y_iCe2wBU1gFbYuBKqUOt8E2yiQ6,Cookie:ss-id=wiw9HsIvCPSF5EFr7a8d; ss-pid=EZ09UDOpQBGzUGuhjRUw; ss-opt=temp; X-UAId=1,Host:SERVER,Referer:""https://SERVER/API/swagger-ui/"",User-Agent:""Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.68 Safari/537.36"",DNT:1}",{},"{"":mini-profiler:"":""https://SERVER:443/API/resource/memberaccounts (28.6 ms)"",AspSessionIDManagerInitializeRequestCalled:True,__route:ServiceStack.Host.RestPath,_requestDurationStopwatch:System.Diagnostics.Stopwatch}",,,,,,PT0.0280572S
3,2017-04-19T20:17:13.1338802Z,200,OK,GET,https://SERVER/API/resource/clubs,/resource/clubs,,{name:clubs},1,wiw9HsIvCPSF5EFr7a8d,10.211.112.29,,https://SERVER/API/swagger-ui/,"{Connection:keep-alive,Accept:""application/json;charset=utf-8,*/*"",Accept-Encoding:""gzip, deflate, sdch, br"",Accept-Language:""en-US,en;q=0.8"",Authorization:Bearer v_-3Y_iCe2wBU1gFbYuBKqUOt8E2yiQ6,Cookie:ss-id=wiw9HsIvCPSF5EFr7a8d; ss-pid=EZ09UDOpQBGzUGuhjRUw; ss-opt=temp; X-UAId=1,Host:SERVER,Referer:""https://SERVER/API/swagger-ui/"",User-Agent:""Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.68 Safari/537.36"",DNT:1}",{},"{"":mini-profiler:"":""https://SERVER:443/API/resource/clubs (40.4 ms)"",AspSessionIDManagerInitializeRequestCalled:True,__route:ServiceStack.Host.RestPath,_requestDurationStopwatch:System.Diagnostics.Stopwatch}",,,,,,PT0.0358807S

0 个答案:

没有答案