我正在尝试从yaml文件配置记录器.在docs.python.org上,我找到了一个如何创建yaml文件的示例,我创建的文件如下所示:
formatters:
simpleFormater:
format: '%(asctime)s - %(levelname)s: %(message)s'
datefmt: '%Y/%m/%d %H:%M:%S'
handlers:
console:
class: logging.StreamHandler
formatter: simpleFormater
level: DEBUG
stream: ext://sys.stdout
file:
class : logging.FileHandler
formatter: simpleFormater
level: WARNING
filename: songinfo.log
loggers:
clogger:
level: DEBUG
handlers: [console]
flogger:
level: WARNING
handlers: [file]
root:
level: DEBUG
handlers: [console, file]
Run Code Online (Sandbox Code Playgroud)
但我找不到如何加载配置的示例.我看到有关加载它的事情:
logging.config.dictConfig(yaml.load(open('logging.conf', 'r')))
Run Code Online (Sandbox Code Playgroud)
但是抛出"ValueError:字典没有指定版本"
所以我的问题是:如何将它加载到Python中的记录器中,以及如何使用clogger和flogger.
我试图在tomcat上的liferay中启用会话复制而没有太多运气.我已经编写了一个小测试,以查看是否正在复制会话,并且它在我在webapps/examples下放置的单独JSP文件中运行良好,但是当我在liferay-porlet中输入相同的代码时,只有JSESSION是正确的.
HttpSession httpSession = request.getSession();
String testTime = (String) httpSession.getAttribute("testTime");
String before = testTime;
testTime = Long.toString(System.currentTimeMillis());
httpSession.setAttribute("testTime", testTime);
String sessionid = httpSession.getId();
System.out.println("JSESSIONID: "+sessionid);
System.out.println("TEST TIME WAS: "+before);
System.out.println("TEST TIME IS: "+testTime);
Run Code Online (Sandbox Code Playgroud)
任何人都知道为什么它不能在liferay-portlet中工作?我已将distributable添加到portlet/WEB-INF/web.xml
编辑1:版本
liferay 6.1.1
Tomcat 7.0.47
Run Code Online (Sandbox Code Playgroud)
编辑2:我尝试了另一个测试.
HttpSession httpSession = request.getSession();
String testTime = (String) httpSession.getAttribute("testTime");
String before = testTime;
if(testTime == null) {
testTime = Long.toString(System.currentTimeMillis());
httpSession.setAttribute("testTime", testTime);
}
String sessionid = httpSession.getId();
System.out.println("JSESSIONID: "+sessionid);
System.out.println("TEST TIME WAS: "+before);
System.out.println("TEST TIME IS: "+testTime);
Run Code Online (Sandbox Code Playgroud)
这次我只设置变量null.它在liferay之外的JSP中可以正常工作,但在liferay中它就像这样.