简体   繁体   中英

In Log4js how do you enable tracing?

In the documentation I could find for Log4js, there is a function isTraceEnabled() , which is defined as

isTraceEnabled

checks if Level Trace is enabled

However, I can't find anywhere how do you actually enable (not check) this trace level. How can you do this?

is<level>Enabled() - returns true if a log event of level (camel case) would be dispatched to the appender defined for the logger's category. For example: logger.isInfoEnabled() will return true if the level for the logger is INFO or lower.

Like the documentation sais, is<level>Enabled() returns true if a log event of that level is enabled.

There are all this levels:

ALL < TRACE < DEBUG < INFO < WARN < ERROR < FATAL < MARK < OFF

Left ones includes the others on the right side.

To set the level of the logger set the level property to the desired one. For example:

var logger = log4js.getLogger();
logger.level = 'debug';

In this concrete case isTraceEnabled() will return false . If you use either trace or all it will return true .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM