https://issues.apache.org/bugzilla/show_bug.cgi?id=46941
--- Comment #4 from Roger Tannous <[email protected]> 2009-04-03 02:57:42 PST --- (In reply to comment #2) > This really seems like you are trying to use levels to accomplish what the > logger hierarchy was designed to do. Many people make the assumption that > since a common pattern for logger names is to follow class names that is the > only way they can be used. Logger names are, in general, are "topics" and you > can use any system that works to give you the type of control that you'd want. > > If you are trying to assign a "topic" (network, database, etc) to a level, > then > you not messing up the "topic" or "audience" concept up with the "severity" > concept. Logger names are really flexible and you can likely accomplish you > goals without nearly as many complications. Using sub-levels is quite different from the standard logger hierarchy in that a new sub level can be introduced without being defined (because it's already a numeric value !) For example, if we have already defined our logging by: logger.referenceDescendingLevels=a,b,(c,d),e,f We can use in the code: Logger.Log("e.11", "log text here"); without having to define sub-level 11 for logging level 'e' anywhere. (<start_of_parenthesis> I'm using here a direct String value as: "e.11", but in reality, you can have a class where levels are defined like: public static String LOG_LEVEL_DATABASE_CONNECTION = "e"; public static String LOG_LEVEL_DATABASE_QUERY = "f"; then use: Logger.Log(LOG_LEVEL_DATABASE_CONNECTION + ".11", "DB connection logging here"); // Remember, I call this Logger.Log(...); function call a " log request " or a " logging request "; you'll find this name in the text below. <end_of_parenthesis> ) Additionally, suppose you have defined your levels and your application is up and running, then after a certain time you need a new logging "level" and need to separate its logging from the rest of the 'logs'; without the proposed technique, you have to 'insert' your new level _in_between_ existing ones. Doesn't this mean that you have to do additional work as you'll have to modify all " logging requests " that are usually "below" the newly introduced one ? At the contrary, using the proposed technique, all you have to do is add the " logging requests " and add your new entry ANYWHERE in the logger.referenceDescendingLevels like: logger.referenceDescendingLevels=a,b,MY_NEW_LEVEL,(c,d),e,f Now within MY_NEW_LEVEL, you can use as many sub-levels as you need without having to define them here. Finally, in the proposed technique, the method does not oblige you to abide by a certain rule as how to design levels and sub-levels. Most importantly, it doesn't tell sub-levels are strictly to be considered as severity ! This can be regarded as your own application design issue. You can use sub-levels for one application as a severity indicator; for others as a sub-category, or even as a dummy number that you plan to deny logging for later after you test your new feature set. Remember that we can do this: logger.referenceDescendingLevels=a,b,MY_NEW_LEVEL,MY_NEW_LEVEL.1,MY_NEW_LEVEL.2,(c,d),e,f Here is an example scenario: Suppose MY_NEW_LEVEL is newly introduced so we can do: logger.referenceDescendingLevels=a,b,MY_NEW_LEVEL,(c,d),e,f supposing: logger.chosenLogLevel=e and the following " logging requests " are all allowed: Logger.Log(MY_NEW_LEVEL, "your log text here"); Logger.Log(MY_NEW_LEVEL + ".0", "your log text here"); // same as first line Logger.Log(MY_NEW_LEVEL + ".1", "your log text here"); Logger.Log(MY_NEW_LEVEL + ".2", "your log text here"); Logger.Log(MY_NEW_LEVEL + ".3", "your log text here"); You do your tests, then want to restrict logging beyond MY_NEW_LEVEL.2 for the logging level MY_NEW_LEVEL. All you'll have to do is: logger.referenceDescendingLevels=a,b,MY_NEW_LEVEL,MY_NEW_LEVEL.1,MY_NEW_LEVEL.2,(c,d),e,f supposing: logger.chosenLogLevel=e As a result, the following " logging requests " are allowed: Logger.Log(MY_NEW_LEVEL, "your log text here"); Logger.Log(MY_NEW_LEVEL + ".0", "your log text here"); // same as first line Logger.Log(MY_NEW_LEVEL + ".1", "your log text here"); Logger.Log(MY_NEW_LEVEL + ".2", "your log text here"); But this one is not: Logger.Log(MY_NEW_LEVEL + ".3", "your log text here"); For this example value, the following " logging requests " for an undefined level is not allowed (i.e., they don't generate an error, but are simply not logged): Logger.Log("x", "your log text here"); Logger.Log("x.5", "your log text here"); The idea in the example is that " logging requests " with levels that are not defined anywhere will not generate any error, they're simply ignored. -- Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the assignee for the bug. --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
