[ 
https://issues.apache.org/jira/browse/LOG4NET-157?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12642634#action_12642634
 ] 

Ron Grabowski commented on LOG4NET-157:
---------------------------------------

class TestClass<T, K>
{
    private static ILog log1 = LogManager.GetLogger(typeof(TestClass<T,K>));
    private static ILog log2 = 
LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

    public TestClass(T arg0, K arg1)
    {
        
    }
}

/* 
------------------------------------------------------------------------------------------------
 */

log4net.Config.XmlConfigurator.Configure();

TestClass<int, int> testClass1 = new TestClass<int, int>(1, 2);
TestClass<string, int> testClass2 = new TestClass<string, int>("1", 2);
TestClass<string, string> testClass3 = new TestClass<string, string>("1", "2");

Console.WriteLine();
Console.WriteLine();

foreach (ILog log in LogManager.GetCurrentLoggers())
{
    Console.WriteLine(log.Logger.Name);
    Console.WriteLine();
}

/* 
------------------------------------------------------------------------------------------------
 */

ConsoleApplication2.Program+TestClass`2[[System.Int32, mscorlib, Version=2.0.0.0
, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.Int32, mscorlib, Ver
sion=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]

ConsoleApplication2.Program+TestClass`2

/* 
------------------------------------------------------------------------------------------------
 */

I'm leaning towards changing the verbage on the webpage to recommend using 
typeof() when working with generic classes.

> FAQ for getting the fully-qualified name of a class
> ---------------------------------------------------
>
>                 Key: LOG4NET-157
>                 URL: https://issues.apache.org/jira/browse/LOG4NET-157
>             Project: Log4net
>          Issue Type: Improvement
>          Components: Documentation
>    Affects Versions: 1.2.10
>         Environment: N/A
>            Reporter: Chris Jerdonek
>            Assignee: Ron Grabowski
>            Priority: Minor
>             Fix For: 1.2.11
>
>
> The FAQ here--
> http://logging.apache.org/log4net/release/faq.html
> states that the following are equivalent ways to obtain a logger:
> (1) private static readonly ILog log = LogManager.GetLogger(typeof(Foo));
> (2) private static readonly ILog log = 
> LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
> However, these constructs seem to behave differently when the classes 
> involved are generic.  When generic classes are involved, I believe the 
> former generates a different logger for each type parameter combination, 
> while the latter generates a different logger if and only if the number of 
> type parameters is different.
> For example,
> TestClass<T, S> can yield "TestClass`2[[System.Int32..." in the former case 
> and "TestClass`2" in the latter.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to