本文整理汇总了Python中org.slf4j.LoggerFactory.getILoggerFactory方法的典型用法代码示例。如果您正苦于以下问题:Python LoggerFactory.getILoggerFactory方法的具体用法?Python LoggerFactory.getILoggerFactory怎么用?Python LoggerFactory.getILoggerFactory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.slf4j.LoggerFactory
的用法示例。
在下文中一共展示了LoggerFactory.getILoggerFactory方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setLogLevel
# 需要导入模块: from org.slf4j import LoggerFactory [as 别名]
# 或者: from org.slf4j.LoggerFactory import getILoggerFactory [as 别名]
def setLogLevel(level, loggerName='ROOT', temporary=True):
"""Set the log level for the given logger.
Args:
level: Logging level to set. Valid levels are 'TRACE', 'DEBUG', 'INFO',
'WARN', 'ERROR', and 'OFF'.
Optional Args:
loggerName: Name of a specific 'logger'. Default value is 'ROOT'.
temporary: Whether or not the logging level should be saved between
McIDAS-V sessions. Be aware that if set to True, loggerName
must be 'ROOT'. Default value is True.
Raises:
ValueError: if temporary is True and loggerName is not 'ROOT'.
"""
if not temporary:
if loggerName != 'ROOT':
raise ValueError(_BAD_LOGGERNAME % (loggerName))
from edu.wisc.ssec.mcidasv.startupmanager.options import OptionMaster
optMaster = OptionMaster.getInstance()
optMaster.getLoggerLevelOption("LOG_LEVEL").setValue(level)
optMaster.writeStartup()
context = LoggerFactory.getILoggerFactory()
logger = context.exists(loggerName)
if not logger:
logger = context.getLogger(loggerName)
currentLevel = logger.getLevel()
if not currentLevel:
currentLevel = logger.getEffectiveLevel()
convertedLevel = currentLevel.toLevel(level, currentLevel.INFO)
logger.setLevel(convertedLevel)
示例2: getLogFile
# 需要导入模块: from org.slf4j import LoggerFactory [as 别名]
# 或者: from org.slf4j.LoggerFactory import getILoggerFactory [as 别名]
def getLogFile():
# TODO(jon): this will likely have to change as the complexity of
# logback.xml increases. :(
# should return the "default" logging context
context = LoggerFactory.getILoggerFactory()
assert context.getName() == 'default', _CONTEXT_ASSERT_MSG % context.getName()
logger = context.getLogger(Logger.ROOT_LOGGER_NAME)
# for now I'll assume that there's only ONE appender per logger
appender = [x for x in logger.iteratorForAppenders()].pop()
assert isinstance(appender, FileAppender), _APPENDER_ASSERT_MSG % type(appender).getCanonicalName()
return appender.getFile()
示例3: __init__
# 需要导入模块: from org.slf4j import LoggerFactory [as 别名]
# 或者: from org.slf4j.LoggerFactory import getILoggerFactory [as 别名]
def __init__(self):
func = formData.get("func")
result = "{}"
resultType = "text/plain"
if func == "reindex":
file = formData.get("file")
portalId = formData.get("portalId")
portalManager = Services.getPortalManager()
if file:
print " * Reindexing: formData=%s" % file
portalManager.indexObject(file)
sessionState.set("reindex/lastResult", "success")
result = '{ status: "ok" }'
elif portalId:
portal = portalManager.get(portalId)
print " * Reindexing: Portal=%s" % portal.name
portalManager.indexPortal(portal)
sessionState.set("reindex/lastResult", "success")
result = '{ status: "ok" }'
else:
sessionState.set("reindex/lastResult", "failed")
result = '{ status: "failed" }'
elif func == "get-state":
result = '{ running: "%s", lastResult: "%s" }' % \
(sessionState.get("reindex/running"),
sessionState.get("reindex/lastResult"))
elif func == "get-log":
context = LoggerFactory.getILoggerFactory()
logger = context.getLogger("au.edu.usq.fascinator.IndexClient")
it = logger.iteratorForAppenders()
appender = logger.getAppender("reindex")
layout = HTMLLayout()
layout.setContext(context)
layout.setPattern("%d%level%msg")
layout.setTitle("Index log")
layout.start()
result = "<table>"
count = appender.getLength()
if count == -1:
result += "<tr><td>Failed</td></tr>"
elif count == 0:
result += "<tr><td>No logging events</td></tr>"
else:
for i in range(0, count):
event = appender.get(i)
result += layout.doLayout(event)
result += "</table>"
resultType = "text/html"
writer = response.getPrintWriter(resultType)
writer.println(result)
writer.close()
示例4: __init__
# 需要导入模块: from org.slf4j import LoggerFactory [as 别名]
# 或者: from org.slf4j.LoggerFactory import getILoggerFactory [as 别名]
def __init__(self):
print " * backup.py: formData=%s" % formData
result = "{}"
resultType = "text/plain"
portalManager = Services.getPortalManager()
func = formData.get("func")
if func == "backup-view":
print " * backup.py: backup portal %s" % portalId
portal = portalManager.get(portalId)
if portal:
portalManager.backup(portal)
sessionState.set("backup/lastResult", "success")
result = '{ status: "ok" }'
else:
sessionState.set("backup/lastResult", "failed")
result = '{ status: "failed" }'
elif func == "get-state":
result = '{ running: "%s", lastResult: "%s" }' % (
sessionState.get("backup/running"),
sessionState.get("backup/lastResult"),
)
elif func == "get-log":
context = LoggerFactory.getILoggerFactory()
logger = context.getLogger("au.edu.usq.fascinator.BackupClient")
it = logger.iteratorForAppenders()
appender = logger.getAppender("backup")
layout = HTMLLayout()
layout.setContext(context)
layout.setPattern("%d%level%msg")
layout.setTitle("Backup log")
layout.start()
result = "<table>"
count = appender.getLength()
if count == -1:
result += "<tr><td>Failed</td></tr>"
elif count == 0:
result += "<tr><td>No logging events</td></tr>"
else:
for i in range(0, count):
event = appender.get(i)
result += layout.doLayout(event)
result += "</table>"
resultType = "text/html"
writer = response.getPrintWriter(resultType)
writer.println(result)
writer.close()
示例5: setLogLevel
# 需要导入模块: from org.slf4j import LoggerFactory [as 别名]
# 或者: from org.slf4j.LoggerFactory import getILoggerFactory [as 别名]
def setLogLevel(level, loggerName='ROOT', temporary=True):
if not temporary:
if loggerName != 'ROOT':
raise ValueError(_BAD_LOGGERNAME % (loggerName))
from edu.wisc.ssec.mcidasv.startupmanager.options import OptionMaster
optMaster = OptionMaster.getInstance()
optMaster.getLoggerLevelOption("LOG_LEVEL").setValue(level)
optMaster.writeStartup()
context = LoggerFactory.getILoggerFactory()
logger = context.exists(loggerName)
if not logger:
logger = context.getLogger(loggerName)
currentLevel = logger.getLevel()
if not currentLevel:
currentLevel = logger.getEffectiveLevel()
convertedLevel = currentLevel.toLevel(level, currentLevel.INFO)
logger.setLevel(convertedLevel)
示例6:
# 需要导入模块: from org.slf4j import LoggerFactory [as 别名]
# 或者: from org.slf4j.LoggerFactory import getILoggerFactory [as 别名]
import logging
from config import Config
from ch.qos.logback.classic import Level
from org.slf4j import LoggerFactory
# Configure the python logger
FORMAT = '%(asctime)-15s %(levelname)s %(message)s'
logging.basicConfig(format=FORMAT)
# Disable the Java logger
java_logger_context = LoggerFactory.getILoggerFactory()
root_logger = java_logger_context.getLogger("ROOT")
root_logger.setLevel(Level.OFF)
# Load the singleton configuration instance to initialize
# the 'kahuna' logger
Config()