Reputation: 311
I am using Serilog to log to LogEntries.com but when I configured the Serilog to send entries enrich with MachineName and ThreadId, they did not show up in LogEntries entries.
How does the entry being sent to LogEntries get formatted. Do I have to manually make them part of the format of those messages and how is that done?
Upvotes: 1
Views: 2291
Reputation: 311
It appears that the LogEntries only processes the message text and not properties in the serilog entry so you are required to add the outputTemplate parameter to the LogEntries sink statement to handle any enriched properties that you use if you want them to show up in serilog furthermore, if you want them to be indexed by LogEntries you need to format them as key value pairs, KVP. I did something like this.
var log = new LoggerConfiguration().ReadFrom.AppSettings()
.Enrich.With(
new MachineNameEnricher(),
new ThreadIdEnricher()
).WriteTo.Logentries(
ConfigurationManager.AppSettings["LogentriesToken"],
outputTemplate: "{Timestamp:G} [{Level}] Mx={MachineName} (Td={ThreadId}) {Message}{NewLine}{Exception}"
).CreateLogger()
Upvotes: 4