Exemplo n.º 1
0
        public void When_Wrapped_Ignore_Wrapper_Methods_In_Callstack()
        {
            //namespace en name of current method
            const string currentMethodFullName = "NLog.UnitTests.LayoutRenderers.CallSiteTests.When_Wrapped_Ignore_Wrapper_Methods_In_Callstack";

            LogManager.Configuration = CreateConfigurationFromString(@"
               <nlog>
                   <targets><target name='debug' type='Debug' layout='${callsite}|${message}' /></targets>
                   <rules>
                       <logger name='*' levels='Warn' writeTo='debug' />
                   </rules>
               </nlog>");

            var logger = LogManager.GetLogger("A");

            logger.Warn("direct");
            AssertDebugLastMessage("debug", $"{currentMethodFullName}|direct");

            LoggerTests.BaseWrapper wrappedLogger = new LoggerTests.MyWrapper();
            wrappedLogger.Log("wrapped");
            AssertDebugLastMessage("debug", $"{currentMethodFullName}|wrapped");
        }
Exemplo n.º 2
0
        public void When_Wrapped_Ignore_Wrapper_Methods_In_Callstack()
        {

            //namespace en name of current method
            const string currentMethodFullName = "NLog.UnitTests.LayoutRenderers.CallSiteTests.When_Wrapped_Ignore_Wrapper_Methods_In_Callstack";

            LogManager.Configuration = CreateConfigurationFromString(@"
               <nlog>
                   <targets><target name='debug' type='Debug' layout='${callsite}|${message}' /></targets>
                   <rules>
                       <logger name='*' levels='Warn' writeTo='debug' />
                   </rules>
               </nlog>");

            var logger = LogManager.GetLogger("A");
            logger.Warn("direct");
            AssertDebugLastMessage("debug", string.Format("{0}|direct", currentMethodFullName));

            LoggerTests.BaseWrapper wrappedLogger = new LoggerTests.MyWrapper();
            wrappedLogger.Log("wrapped");
            AssertDebugLastMessage("debug", string.Format("{0}|wrapped", currentMethodFullName));


        }