Custom Layout Renderer - StackFrame is null

3 messages Options
Embed this post
Permalink
Thomas Eigner

Custom Layout Renderer - StackFrame is null

Reply Threaded More More options
Print post
Permalink
Hello,

I'm currenty building a customized version of the CallSiteLayoutRenderer. I had a look at the original sourcecode and wanted to to s.th. like

protected override void Append(StringBuilder builder, LogEventInfo logEvent)
        {
            StackFrame frame = logEvent.UserStackFrame;

            if (frame != null)
            {
                ... do something...
            }
            else
                builder.Append("Stackframe is null");
        }

From the NLog trace i can see the assembly is loaded correctly. I can see that it works because i get "Stackframe is null" text in the logfile.

But what could be the reason why the UserStackFrame is null ? Without this object I can't realize the function I need...

Thank you very much for any hints !

Regards, Thomas
Jaroslaw Kowalski

Re: Custom Layout Renderer - StackFrame is null

Reply Threaded More More options
Print post
Permalink
Can you check your NeedsStackTrace ? In NLog v1 it should look something like:
 
        /// <summary>
        /// Checks whether the stack trace is requested.
        /// </summary>
        /// <returns>2 when the source file information is requested, 1 otherwise.</returns>
        protected internal override int NeedsStackTrace()
        {
            return _sourceFile ? 2 : 1;
        }
 
This will be changed in v2 to use Enum instead of magic numbers.
 
Jarek
On Fri, Aug 21, 2009 at 7:03 AM, Thomas Eigner (via Nabble) - No Reply <[hidden email]> wrote:
Hello,

I'm currenty building a customized version of the CallSiteLayoutRenderer. I had a look at the original sourcecode and wanted to to s.th. like

protected override void Append(StringBuilder builder, LogEventInfo logEvent)
        {
            StackFrame frame = logEvent.UserStackFrame;

            if (frame != null)
            {
                ... do something...
            }
            else
                builder.Append("Stackframe is null");
        }

From the NLog trace i can see the assembly is loaded correctly. I can see that it works because i get "Stackframe is null" text in the logfile.

But what could be the reason why the UserStackFrame is null ? Without this object I can't realize the function I need...

Thank you very much for any hints !

Regards, Thomas

Thomas Eigner

Re: Custom Layout Renderer - StackFrame is null

Reply Threaded More More options
Print post
Permalink
Ah ok... i think something went wrong here.
Will try this on monday...

Have a nice weekend and thank you
Thomas