Author | Message |
---|---|
raylongma1018
Posts: 81
|
Posted 18:16 Aug 04, 2015 |
i see from your exam-example you put a logger.info in the public String login(email,password,session) method. I try to build the loggingtest like you did in the video lecture and test this class in the loggintest.java, but i am not able to test. the one you the logger in the video lecture is in the method output with return type void. but login return type is string. I just want to know how to test the logger.info msg from your login method.Please help |
cysun
Posts: 2935
|
Posted 19:36 Aug 04, 2015 |
Just run the project and try logging in. |
raylongma1018
Posts: 81
|
Posted 20:23 Aug 04, 2015 |
when i read your log4j.xml I just wonder why you put the logger name to be "csjobs" rather than just put in more specific packet like "csjobs.web.controller"? also I want to ask is all the logger msgs like, trace, warning, info ..etc to be read by the programmers? also why you only put logger.info the login method, why you skip other logger msg level such as warning, debug,trace...?isn't it a good practice for us programmer put all the logger msg level everytime when we need it? I thoght the log4j.xml is the one control the llogger msg level , so that's why i believe we should always put all the 5 logger msgs |
cysun
Posts: 2935
|
Posted 08:27 Aug 05, 2015 |
The exam code is not supposed to be complete. I only did one logger.info() to make sure logging works. The logger is "csjobs" in log4j.xml because I may also want to have logging in other parts of my code, not just controllers. You seem to to have some misunderstanding about message levels. When you want to output a logging message, you pick one message level and output the message at that level; you don't output the same message several times at multiple levels - the code in the log4j example is only for demonstration purpose. |