Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8596111
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T00:35:57+00:00 2026-06-12T00:35:57+00:00

The event context layout renderer gets its parameters from the LogEventInfo parameter, for example:

  • 0

The event context layout renderer gets its parameters from the LogEventInfo parameter, for example:
http://nlog-project.org/wiki/Event-context_layout_renderer

However the LogEventInfo parameter is available in only 2 of the Log method signatures:

     public void Log(Type wrapperType, LogEventInfo logEvent)
     public void Log(LogEventInfo logEvent)

How can I pass the LogEventInfo if I want to use other Log methods, for example:

     public void Log<T>(LogLevel level, IFormatProvider formatProvider, T value)
     public void Log(LogLevel level, LogMessageGenerator messageFunc)
     public void LogException(LogLevel level, [Localizable(false)] string message, Exception ecxception)

Assuming this is not possible in NLog 2.0, what workarounds are available?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T00:35:58+00:00Added an answer on June 12, 2026 at 12:35 am

    The latter Log methods you have listed are really just convenience methods over the first two. In other words, they just construct LogEventInfos themselves. When you use the first two methods, you’re circumventing the convenience for the sake of greater customization.

    To recreate the functionality of the convenience methods, you have to play around a bit with LogEventInfo.

    // instead of..
    Log<T>(LogLevel level, IFormatProvider formatProvider, T value)
    // use:
    LogEventInfo.Create<T>(LogLevel level, <log name>, IFormatProvider formatProvider, T value)
    
    // instead of..
    Log(LogLevel level, LogMessageGenerator messageFunc)
    // use:
    if (Log.IsEnabled(level))
        Log.Log(LogEventInfo.Create(level, Log.Name, messageFunc()));
    
    // instead of..
    LogException(LogLevel level, string message, Exception exception)
    // use:
    LogEventInfo.Create(LogLevel level, <log name>, string message, Exception exception)
    

    The plus side of doing it with a LogEventInfo, again, is that you can then go on to customize the logging event even further before calling Log().

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing an event delegating plugin that takes 4 params: context = String
I want to get clicked row from listview child's onClick event. I am able
I want to create an event content type with one field Dates contains a
I have 2 websites with similar content types. Let's say an event-content type with
Execution Context nested Events Hi, I would like to know a little bit more
the context i use Spooler Events API to capture events generated by the spooler
Content type Events has intro, body and an event date field (using Date module).
When setting a content div's height during a jQuery dialog 'dialogresize' event, the div's
So, I'm making this context menus, which looks great in all major browsers, even
I'm creating a popup window in a listactivity in the event onListItemClick. LayoutInflater inflater

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.