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();
protected static readonly Logger _logger = LogManager.GetCurrentClassLogger();
public void MakeLogNoise(){
_logger.Debug(new Exception(), "Error for url {0}. Status code: {1} Error Message: {2}", "SampleUrl", "500", "Error Message");
_logger.Debug(new Exception(), "Error for url {url}. Status code: {statusCode} Error Message: {errorMessage}", "SampleUrl", "500", "Error Message");