public void TestCreateUnityConsoleTarget() { // CreateUnityConsoleTarget var ucTargetWithoutArgs = NLogFactory.CreateUnityConsoleTarget(); Assert.AreEqual(null, ucTargetWithoutArgs.Name); Assert.AreEqual("'[${level:uppercase=true}] [${callsite}] ${message}${newline}${exception:format=Message, ToString:separator=\n}'", ucTargetWithoutArgs.Layout.ToString()); var ucTargetWithName = NLogFactory.CreateUnityConsoleTarget("UCTarget"); Assert.AreEqual("UCTarget", ucTargetWithName.Name); Assert.AreEqual("'[${level:uppercase=true}] [${callsite}] ${message}${newline}${exception:format=Message, ToString:separator=\n}'", ucTargetWithName.Layout.ToString()); var ucTargetWithLayout = NLogFactory.CreateUnityConsoleTarget("UCTarget", "${message}"); Assert.AreEqual("UCTarget", ucTargetWithLayout.Name); Assert.AreEqual("'${message}'", ucTargetWithLayout.Layout.ToString()); }
void ConfigureLogger(NLog.Config.LoggingConfiguration config) { var jsonParams = new Dictionary <string, string>() { { "hoge", "fuga" }, { "foo", "bar" } }; // initialize targets var ucTarget = NLogFactory.CreateUnityConsoleTarget("UCTargetByCode"); var wsTarget = NLogFactory.CreateJsonWebServiceTarget("JWSTargetByCode", "http://localhost:1234/nlog", jsonParams); var mTarget = new MemoryTarget("MTargetByCode"); mTarget.Layout = "[${level:uppercase=true}] ${message}"; // add rules config.AddRule(LogLevel.Trace, LogLevel.Fatal, ucTarget); config.AddRule(LogLevel.Trace, LogLevel.Fatal, wsTarget); config.AddRule(LogLevel.Trace, LogLevel.Fatal, mTarget); }