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

  • Home
  • SEARCH
  • 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 56419
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T17:31:53+00:00 2026-05-10T17:31:53+00:00

I’m doing some research into using log4net, and I found the IObjectRenderer interface interesting.

  • 0

I’m doing some research into using log4net, and I found the IObjectRenderer interface interesting. It would allow us to control how types are logged and provide a different, possibly more user-friendly ToString() implementation. I just started looking at log4net though, and can’t seem to find a logical way to programmatically set up the association between types and renderers.

I found that this can be set up in the XML configuration file by reading the manual, but it didn’t give me any hints about programmatically adding these. It seems to me that you’d rather have a programmatic object renderer in some cases, so I’m curious how to do this.

  • 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. 2026-05-10T17:31:54+00:00Added an answer on May 10, 2026 at 5:31 pm

    I poked around with it some while writing the question and came up with this:

    using System.IO; using log4net; using log4net.Config; using log4net.ObjectRenderer; using log4net.Util;  namespace ConsoleApplication1 {     class Program     {         static void Main(string[] args)         {             BasicConfigurator.Configure();              ILog log = LogManager.GetLogger(typeof(Program));             var repo = LogManager.GetRepository();             repo.RendererMap.Put(typeof(Foo), new FooRenderer());              var fooInstance = new Foo() { Name = 'Test Foo' };             log.Info(fooInstance);         }     }      internal class Foo     {         public string Name { get; set; }     }      internal class FooRenderer : log4net.ObjectRenderer.IObjectRenderer     {         public void RenderObject(RendererMap rendererMap, object obj, TextWriter writer)         {             if (obj == null)             {                 writer.Write(SystemInfo.NullText);             }              var fooInstance = obj as Foo;             if (fooInstance != null)             {                 writer.Write('', fooInstance.Name);             }             else             {                 writer.Write(SystemInfo.NullText);             }         }     } }

    I am not certain if this is the correct way to do this, but I do know that it worked.

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

Sidebar

Ask A Question

Stats

  • Questions 191k
  • Answers 191k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer So basically, what you really want is to be given… May 12, 2026 at 6:15 pm
  • Editorial Team
    Editorial Team added an answer I want MyObject to be serialized into a string using… May 12, 2026 at 6:15 pm
  • Editorial Team
    Editorial Team added an answer Here's the solution, using keyword "nosvnemail": set REPOS=%1 set REV=%2… May 12, 2026 at 6:15 pm

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
In order to apply a triggered animation to all ToolTip s in my app,
I have a French site that I want to parse, but am running into
I have text I am displaying in SIlverlight that is coming from a CMS

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.