.netlogentries

LogEntries without a .config file in a .NET application


I am reading the article on logging from .NET Applications found here. I would like to do the functional equivalent without using a .config file. Does anyone have code samples for that? Thanks


Solution

  • I think this code is wrong... could you check? By the way, I made work this way:

        target.Token = "LOG_TOKEN";
        target.Ssl = false;
        target.Debug = true;
        target.Name = "Logentries";
        target.Layout = "${date:format=ddd MMM dd} ${time:format=HH:mm:ss} ${date:format=zzz yyyy} ${logger} : ${LEVEL}, ${message}";
        target.HttpPut = false;
    
        var config = new LoggingConfiguration();
        config.AddTarget("Logentries", target);
    
        var loggingRule = new LoggingRule("*", LogLevel.Debug, target);
        config.LoggingRules.Add(loggingRule);
    
        LogManager.Configuration = config;
        LogManager.Configuration.Reload();