There has been several users that have asked for a global log level in Microlog. My initial thought was that this is hard to do, if we should not implement a logging hierarchy. I would like to avoid logging hierarchies, since I think that this would make the Microlog core to complicated and big. Anyway I found a solution to add a global log level to the existing Microlog version, without implementing a logger hierarchy.
The solution is rather simple. You have a method called
setGlobalLogLevel()
in the Logger
class. This is used for all Logger
instances, except for those who override it. We have added the method getEffectiveLevel()
to check the effective level for each Logger
. This method is also found in Log4j, but in that case is has another semantic meaning. In Microlog we have a global level and an individual level, whereas in Log4j it is the hierarchy of Logger
objects that decide the effective level.The setup in the properties file looks like this:
The first line is used for setting the global log level. This is similar to how it was before. The new ability is used on the 2nd line, where the log level is set for a particular class.microlog.level=DEBUG
microlog.level.net.sf.microlog.example.PropertiesConfigMidlet=TRACE
I hope that this solution would suffice for most users. The next step is probably to introduce a hierachy of loggers. Since this will break the compability, this will be introduced in Microlog 2.0. But we have not still decided whether or not we will introduce a Logger hierarchy. What do you think?
1 comment:
Hi,
Thanks for providind very useful information about to this liberary.Micrilog powerful logging library for mobile devices,It is smally but works very fast especially for mpbile devices.
Post a Comment