Most logging packages use a fixed set of named severities. For example, Log4J / Log4Net uses TRACE, DEBUG, INFO, WARN, ERROR and FATAL.
JSNLog doesn't use named severities or levels. Instead, a severity or level is simply a number. The higher the number, the greater the severity.
This provides these advantages:
- You can now have as many severities or levels as you want, rather than just 6 in the case of Log4J / Log4Net.
- JSNLog needs to be able to talk to a wide variety of server side logging packages, with their own severities. Translating a numeric severity to whatever the target package uses is more natural than translating from one arbitrary set of severities to another.
For examples of the use of numeric severities, see the log Method and the level property of the setOptions Method of loggers and appenders.
Named severities for convenience
Log4J / Log4Net style named severities are probably more familiar to most developers than numeric severities. So JSNLog provides convenience methods that use those severities:
To create log messages with a named severity,
such as the
To get the numeric severity of a named severity, such as the
When translating from Log4J / Log4Net style named severities to its own numeric severities, JSNLog uses this mapping:
|From Named Severity||To Numeric Severity|
And from numeric severity to named severity:
|From Numeric Severity||To Named Severity|
|up to 1000||TRACE|
|1001 - 2000||DEBUG|
|2001 - 3000||INFO|
|3001 - 4000||WARN|
|4001 - 5000||ERROR|
|5001 and up||FATAL|