How to Know the current log level using log4net to store in database in an application.
If you mean the enabled levels then:
bool IsDebugEnabled { get; }
bool IsInfoEnabled { get; }
bool IsWarnEnabled { get; }
bool IsErrorEnabled { get; }
bool IsFatalEnabled { get; }
if all of them are true then the level would be Debug, if Info and above is enabled then it is info and so ..
you can check like this
if(myLogger.IsDebugEnabled)
return "Debug";
else if(myLogger.IsInfoEnabled)
return "Info";
else if(myLogger.IsWarnEnabled)
return "Warn";
else if(myLogger.IsErrorEnabled)
return "Error";
else if(myLogger.IsFatalEnabled)
return "Fatal";
else
return "None";
You can also get the specific level by this:
((log4net.Repository.Hierarchy.Logger)mylogger.Logger).Level
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With