/// <summary> /// Do something when new log is added. /// </summary> /// <param name="methodCall">Method that accepts IList<string>, which will be logs.</param> public static void SetTargetInvoking(InvocableMemoryTarget.MethodCall methodCall) { InvocableMemoryTarget invocableMemoryTarget = GetInvocableMemoryTarget(); if (invocableMemoryTarget != null) { invocableMemoryTarget.MethodToCall = methodCall; } }
public static void InitializeLogger() { LoggingConfiguration config = new LoggingConfiguration(); TargetWithLayout target = new InvocableMemoryTarget(INVOCABLE_MEMORY_TARGET_NAME, MEMORY_TARGET_NAME) { Layout = "${shortdate} ${time} [${level:format=FullName}] ${message}" // https://nlog-project.org/config/?tab=layout-renderers }; config.AddRuleForAllLevels(target); LogManager.Configuration = config; }
public static List <string> GetLogs() { InvocableMemoryTarget invocableMemoryTarget = GetInvocableMemoryTarget(); return(invocableMemoryTarget?.MemoryTarget?.Logs as List <string>); }