Liferay: what is the default approach for logging in Liferay?

╄→尐↘猪︶ㄣ 提交于 2020-01-23 06:48:18

问题


By development of portlets, hooks etc. I have seen different approaches for logging in Liferay. Is there default logging approach - The Liferay Way - that I can use.

1.How to initialize the logger?

2.How to config the logging levels?

I have seen that the logging level can be modified direct in Liferay - Control Panel, is it good? How can I combine it with config file?


回答1:


You can find the basic logging information you need in Liferay Documentation.

Summarized: you should instantiate your Log4j Log object through LogFactory, identified by the current class name, then enable that log category on the control panels "Log level" settings tab.




回答2:


Logging comes ready to go out of the box.

Inside your class variable declarations use this:

private static Log log = LogFactory.getLog(name-of-class.class);

Then down in your code use this to output to the catalina.out file in liferay/tomcat/logs

     log.info("Some info you want to see");

Or

     log.error("This error was thrown!");


来源:https://stackoverflow.com/questions/9784183/liferay-what-is-the-default-approach-for-logging-in-liferay

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!