Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 943
Mark Avatar asked Mar 20 '12 09:03

Mark


2 Answers

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.

like image 76
xea Avatar answered Nov 09 '22 12:11

xea


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!");
like image 1
Sean Gildea Avatar answered Nov 09 '22 13:11

Sean Gildea