I am using log4javascript to log and track the issues in my JavaScript code. I have seen similar logging aids before but I am having difficulty in understanding how each of these log levels should be used to be more useful and productive.
Most of the time I end up logging debug, info or trace without being really aware of how productive each of them are or not. As the code grows larger and larger it's getting tough and I feel logs are more trouble than help.
Can someone give me some guidelines/help so that I can use the logging mechanism well.
Following are the different log levels supported by the log4javascript:
log4javascript.Level.ALL
log4javascript.Level.TRACE
log4javascript.Level.DEBUG
log4javascript.Level.INFO
log4javascript.Level.WARN
log4javascript.Level.ERROR
log4javascript.Level.FATAL
I'm the author of log4javascript and I use it every day in my work. Here's how I use it:
debug()
andtrace()
most frequently. I usetrace()
for logging low level operations when trying to hunt down a bug anddebug()
for more general logging of program flow. I have the console threshold set toDEBUG
for my usual coding so that I don't have trace messages cluttering up the log and then switch it toALL
when I need to see the trace messages.info()
quite a bit, usually to make particular messages stand out a little in the logging console.group()
(see http://log4javascript.org/docs/manual.html#loggers) to group logging for a particular operation and allows me to expand and collapse chunks of logging. Groups can also be nested.For example:
In the logging initialization code:
This stuff is common to all log4x logging frameworks, so documentation from log4j or log4net will apply. For example, the old but still relevant log4j short manual may help.