Version 1.3.0
- The formatting of the
messageXML element has changed. If a log event is coming fromMicrosoft.Extensions.Logging, then the message is now formatted by switching off quoting of strings. The formatting of properties remains unchanged.
Before (1.2.0)
<event logger="Microsoft.EntityFrameworkCore.Database.Command" timestamp="2003-01-04T15:09:26.535+01:00" level="INFO">
<properties>
<data name="elapsed" value="10" />
<!-- ... -->
<data name="EventId.Id" value="20101" />
<data name="EventId.Name" value="Microsoft.EntityFrameworkCore.Database.Command.CommandExecuted" />
</properties>
<message>Executed DbCommand ("10"ms) [Parameters=[""], CommandType='Text', CommandTimeout='30']"
""SELECT COUNT(*) FROM \"sqlite_master\" WHERE \"type\" = 'table' AND \"rootpage\" IS NOT NULL;"</message>
</event>After (1.3.0)
<event logger="Microsoft.EntityFrameworkCore.Database.Command" timestamp="2003-01-04T15:09:26.535+01:00" level="INFO">
<properties>
<data name="elapsed" value="10" />
<!-- ... -->
<data name="EventId.Id" value="20101" />
<data name="EventId.Name" value="Microsoft.EntityFrameworkCore.Database.Command.CommandExecuted" />
</properties>
<message>Executed DbCommand (10ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
SELECT COUNT(*) FROM "sqlite_master" WHERE "type" = 'table' AND "rootpage" IS NOT NULL;</message>
</event>- The message formatting behaviour can be configured with the new
UseMessageFormatter()method of the options' builder. For example, all log events with theUppercaseMessageproperty set totruecan have their messages uppercased.
var formatter = new Log4NetTextFormatter(options => options.UseMessageFormatter((logEvent, formatProvider) =>
{
if (logEvent.Properties.TryGetValue("UppercaseMessage", out var up) && up is ScalarValue { Value: true })
{
return logEvent.RenderMessage(formatProvider).ToUpperInvariant();
}
return logEvent.RenderMessage(formatProvider);
}));