Reputation: 860
is something like the following available ?
<logger name="mylogger" level="ERROR" defaultLevel="INFO">
So when someone changes the logger configuration in run time with an invalid log level (example: in case of a typo) it should log with loglevel INFO.
Please advise.
Upvotes: 0
Views: 294
Reputation: 651
Yes, ofc you can do this but you need to implement it as so.
here is a code snippet from Log4j which if provided an invalid log will be set to your specified default value
public static Level toLevel(int val, Level defaultLevel) {
switch(val) {
case -2147483648:
return ALL;
case 5000:
return TRACE;
case 10000:
return DEBUG;
case 20000:
return INFO;
case 30000:
return WARN;
case 40000:
return ERROR;
case 50000:
return FATAL;
case 2147483647:
return OFF;
default:
return defaultLevel;
}
Upvotes: 1