public static void Main()
var config = new NLog.Config.LoggingConfiguration();
var logconsole = new NLog.Targets.ConsoleTarget("console");
config.AddRule(LogLevel.Debug, LogLevel.Fatal, logconsole);
var jsonLayout = new JsonLayout()
new JsonAttribute("time", "${longdate}"),
new JsonAttribute("message", "${message}"),
new JsonAttribute("exceptionMessage", "${exception:format=Message}"),
new JsonAttribute("innerException", new JsonLayout
new JsonAttribute("type", "${exception:format=:innerFormat=Type:MaxInnerExceptionLevel=1:InnerExceptionSeparator=}"),
new JsonAttribute("message", "${exception:format=:innerFormat=Message:MaxInnerExceptionLevel=1:InnerExceptionSeparator=}"),
jsonLayout.IncludeAllProperties = true;
logconsole.Layout = jsonLayout;
NLog.LogManager.Configuration = config;
Console.WriteLine("Error while initializing nlog " + ex.Message.ToString());
new LoggingTest().MakeLogNoise();
public string C {get;set;}
protected static readonly Logger _logger = LogManager.GetCurrentClassLogger();
public void MakeLogNoise(){
var a = new A() { B = 5, C = "Test123" };
var b = new A() { B = a.B, C = a.C};
_logger.Info("Test: {@value1}", a);
_logger.Info("Test: {@value1}", b);