Is it possible to change the source name thru code? My solution has several modules and I want to separate them when viewing the logs.
<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<targets>
<target xsi:type="EventLog" name="eventlog" layout="${message}" log="Application" source="MyAwesomeSolution"/>
</targets>
<rules>
<logger name="*" minlevel="Info" writeTo="eventLog" />
</rules>
</nlog>
Also, how do I log objects as xml? e.g. if I do this – logger.Info("Results - {0}", person); I want to view the person object as XML in my event log. Is it possible?
Initalize your Logger object with
then you can add
${callsite}to your layout in config filee.g.
More info @ ${callsite} is here.