You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
when you go to the admin > system > log. You'll see a different timezone date than in the detail view. The UTC is not converted correctly to the users' time. I corrected the bug by updating the script from
var gridModel = new DataSourceResult
{
Data = logItems.Select(x => new LogModel
{
Id = x.Id,
LogLevel = x.LogLevel.GetLocalizedEnum(_localizationService, _workContext),
ShortMessage = x.ShortMessage,
little hack here:
ensure that FullMessage is not returned
otherwise, we can get the following error if log records have too long FullMessage:
"Error during serialization or deserialization using the JSON JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property. "
also it improves performance
FullMessage = x.FullMessage,
FullMessage = "",
IpAddress = x.IpAddress,
CustomerId = x.CustomerId,
CustomerEmail = x.Customer != null ? x.Customer.Email : null,
PageUrl = x.PageUrl,
ReferrerUrl = x.ReferrerUrl,
CreatedOn = _dateTimeHelper.ConvertToUserTime(x.CreatedOnUtc, DateTimeKind.Utc)
}),
Total = logItems.TotalCount
};
to
var logs = new List();
foreach(var log in logItems)
{
logs.Add(new LogModel {
Id = log.Id,
LogLevel = log.LogLevel.GetLocalizedEnum(_localizationService,_workContext),
ShortMessage = log.ShortMessage,
FullMessage="",
IpAddress=log.IpAddress,
CustomerId=log.CustomerId,
CustomerEmail = log.Customer !=null ? log.Customer.Email:null,
PageUrl = log.PageUrl,
ReferrerUrl=log.ReferrerUrl,
CreatedOn = _dateTimeHelper.ConvertToUserTime(log.CreatedOnUtc,DateTimeKind.Utc)
});
}
var gridModel = new DataSourceResult
{
Data = logs,
Total = logItems.TotalCount
};
works now
The text was updated successfully, but these errors were encountered:
although it may appear that logically nothing changed, but for some reason as I was scratching my head, the convert to local time for this particular call was not working. Please use the debug mode, you'll see for yourself, unless I'm wrong.
when you go to the admin > system > log. You'll see a different timezone date than in the detail view. The UTC is not converted correctly to the users' time. I corrected the bug by updating the script from
var gridModel = new DataSourceResult
{
Data = logItems.Select(x => new LogModel
{
Id = x.Id,
LogLevel = x.LogLevel.GetLocalizedEnum(_localizationService, _workContext),
ShortMessage = x.ShortMessage,
little hack here:
ensure that FullMessage is not returned
otherwise, we can get the following error if log records have too long FullMessage:
"Error during serialization or deserialization using the JSON JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property. "
also it improves performance
FullMessage = x.FullMessage,
FullMessage = "",
IpAddress = x.IpAddress,
CustomerId = x.CustomerId,
CustomerEmail = x.Customer != null ? x.Customer.Email : null,
PageUrl = x.PageUrl,
ReferrerUrl = x.ReferrerUrl,
CreatedOn = _dateTimeHelper.ConvertToUserTime(x.CreatedOnUtc, DateTimeKind.Utc)
}),
Total = logItems.TotalCount
};
to
var logs = new List();
foreach(var log in logItems)
{
logs.Add(new LogModel {
Id = log.Id,
LogLevel = log.LogLevel.GetLocalizedEnum(_localizationService,_workContext),
ShortMessage = log.ShortMessage,
FullMessage="",
IpAddress=log.IpAddress,
CustomerId=log.CustomerId,
CustomerEmail = log.Customer !=null ? log.Customer.Email:null,
PageUrl = log.PageUrl,
ReferrerUrl=log.ReferrerUrl,
CreatedOn = _dateTimeHelper.ConvertToUserTime(log.CreatedOnUtc,DateTimeKind.Utc)
});
}
works now
The text was updated successfully, but these errors were encountered: