Liferay: what is the default approach to enter Liferay?

When developing portlets, hooks, etc. I have seen various approaches to registering with Liferay. Is there a default logging method - The Liferay Way - that I can use.

1. How to initialize the registrar?

2.How to configure logging levels?

I saw that the logging level can be changed directly in Liferay - Control Panel, is this good? How can I combine it with a configuration file?

+6
source share
2 answers

You can find basic registration information in the Liferay Documentation .

Summarized: you must create an instance of the Log4j Log object through the LogFactory identified by the current class name, then enable this log category in the settings tab of the "Log level" control panel.

+9
source

Logging is ready to work out of the box.

Inside class variable declarations, use this:

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

Then 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!"); 
+1
source

Source: https://habr.com/ru/post/911181/


All Articles