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 6819213
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T21:16:45+00:00 2026-05-26T21:16:45+00:00

I run into the same issue described there: Another StackOverflow Question I need to

  • 0

I run into the same issue described there:
Another StackOverflow Question

I need to log to file and method calling.
The problem is that there are lot of “debug” level logging messages which are more detailled.
I need them to log to file. But the method should only receive logging messages above debug level.

So the SplitGroupTarget doesn’t fullfill my requirements.
Is there any solutions or workarounds for this problem?

Additionally i found this entry in the NLog forum with a similiar problem in 2006 – but with no answer yet: NLog Forum

EDIT1: I forgot to mention that i want to configure this programmatically.
According to your answer i tried it in the following way, but only the last target gets logged.

SimpleConfigurator.ConfigureForTargetLogging(methodCallTarget, LogLevel.Debug);
SimpleConfigurator.ConfigureForTargetLogging(fileTarget, LogLevel.Debug);
  • 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-05-26T21:16:45+00:00Added an answer on May 26, 2026 at 9:16 pm

    I just found the solution to log multiple targets programmatically.

    I just don’t use the SimpleConfigurator but the LogManager to set the NLog.LoggingConfiguration to its property.

    So i came out with following code snippet:

    // define the targets
    // ......
    
    // create configuration object and set previously created targets
    LoggingConfiguration configuration = new LoggingConfiguration();
    configuration.AddTarget("methodCall", methodCallTarget);
    configuration.AddTarget("logfile", fileTarget);
    
    // create logging rules where i can specify the minimum log levels
    // and add them to the configuration objects LoggingRules Enumerable.
    LoggingRule logFileRule = new LoggingRule("*", NLog.LogLevel.Debug, fileTarget);
    configuration.LoggingRules.Add(logFileRule);
    
    LoggingRule methodCallRule = new LoggingRule("*", NLog.LogLevel.Info, methodCallTarget);
    configuration.LoggingRules.Add(methodCallRule);
    
    // Finally set the configuration object to the LogManagers Configuration property
    LogManager.Configuration = configuration;
    

    Thanks for your answers!

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

Sidebar

Related Questions

I've run into the same problem as found in this question . However, I
Ive run into the issue where I need to query 2 separate databases(same instance)
I always run into the same problem when creating web pages. When I add
Ran into this problem today, posting in case someone else has the same issue.
I've run into the same issue presented by the commenter here: Django South -
I run into follow problem. Did I miss anything? Association.all().count() 1 Association.all().fetch(1) [Association(**{'server_url': u'server-url',
I run into the following issue semi-regularly: I make changes to XAML or some
I run into the following errors when i try to store a large file
I run into an interesting problem while was using combos in input form. My
I often run into the following problem. I work on some changes to a

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.