LogLevel Values

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

LogLevel Values

Jonathan Parker
Hi,

Just a quick question regarding Filters and log levels.

The documentation says that LogLevel.FromOrdinal returns:

The LogLevel instance. For 0 it returns Debug, 1 gives Info and so on


However the LogLevel constructor looks like this:

static LogLevel()
{
    int num = 0;
    Trace = new LogLevel("Trace", num++);
    Debug = new LogLevel("Debug", num++);
    Info = new LogLevel("Info", num++);
    Warn = new LogLevel("Warn", num++);
    Error = new LogLevel("Error", num++);
    Fatal = new LogLevel("Fatal", num++);
    Off = new LogLevel("Off", num++);
    _levelByOrdinal = new LogLevel[] { Trace, Debug, Info, Warn, Error, Fatal, Off };
    MinLevel = _levelByOrdinal[0];
    MaxLevel = _levelByOrdinal[_levelByOrdinal.Length - 2];
}

Trace is added first to the _levelByOrdinal array which means it will have index 0.
and the FromOrdinal method looks like this:

public static LogLevel FromOrdinal(int ordinal)
{
    return _levelByOrdinal[ordinal];
}

Does this mean that FromOrdinal will actually return Trace when 0 is passed in?

Thanks,
Jonathan.

------------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It is the best place to buy or sell services for
just about anything Open Source.
http://p.sf.net/sfu/Xq1LFB
_______________________________________________
Nlog-list mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/nlog-list
Reply | Threaded
Open this post in threaded view
|

Re: LogLevel Values

Jarek Kowalski
Administrator
You're right. The documentation is inaccurate in this case.
 
Debug will return 1.
 
Jarek
----- Original Message -----
Sent: Sunday, January 11, 2009 7:13 PM
Subject: [Nlog-list] LogLevel Values

Hi,

Just a quick question regarding Filters and log levels.

The documentation says that LogLevel.FromOrdinal returns:

The LogLevel instance. For 0 it returns Debug, 1 gives Info and so on


However the LogLevel constructor looks like this:

static LogLevel()
{
    int num = 0;
    Trace = new LogLevel("Trace", num++);
    Debug = new LogLevel("Debug", num++);
    Info = new LogLevel("Info", num++);
    Warn = new LogLevel("Warn", num++);
    Error = new LogLevel("Error", num++);
    Fatal = new LogLevel("Fatal", num++);
    Off = new LogLevel("Off", num++);
    _levelByOrdinal = new LogLevel[] { Trace, Debug, Info, Warn, Error, Fatal, Off };
    MinLevel = _levelByOrdinal[0];
    MaxLevel = _levelByOrdinal[_levelByOrdinal.Length - 2];
}

Trace is added first to the _levelByOrdinal array which means it will have index 0.
and the FromOrdinal method looks like this:

public static LogLevel FromOrdinal(int ordinal)
{
    return _levelByOrdinal[ordinal];
}

Does this mean that FromOrdinal will actually return Trace when 0 is passed in?

Thanks,
Jonathan.


------------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It is the best place to buy or sell services for
just about anything Open Source.
http://p.sf.net/sfu/Xq1LFB


_______________________________________________
Nlog-list mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/nlog-list

------------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It is the best place to buy or sell services for
just about anything Open Source.
http://p.sf.net/sfu/Xq1LFB
_______________________________________________
Nlog-list mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/nlog-list
NLog Blog