Foren

Documentation about Lifeary Logging and Log4J

thumbnail
Denis Signoretto, geändert vor 9 Jahren.

Documentation about Lifeary Logging and Log4J

Expert Beiträge: 375 Beitrittsdatum: 21.04.09 Neueste Beiträge
Hi,

I was reading the user guide documentation page about Liferay Logging's System and in particular the paragraph about how to use logging in your classes or custom plugins. IMHO, it should be modified with a more precise description.

If you want to set the log level for one of your own classes in a deployed plugin, you can register that class with Liferay to can control the log levels more easily, so long as your class uses Log4J to do its logging.

You will first need to implement Log4J logging in your class, with a statement such as the following (taken from Liferay’s JCRStore class):

private static Log _log = LogFactory.getLog(JCRStore.class);


You would then use this _log variable to create log messages in your code for the various logging levels:

_log.error("Reindexing " + node.getName(), e1);



IMHO, it should be modified with a little insight about how Liferay implement logging through Log4j and exposes interfaces Log and LogFactory that you can use in your custom classes.

One more useful information it's that log level modification through console does not persist between Liferay restarts.

WDYT ?

Best regards,
Denis.
thumbnail
David H Nebinger, geändert vor 9 Jahren.

RE: Documentation about Lifeary Logging and Log4J

Liferay Legend Beiträge: 14916 Beitrittsdatum: 02.09.06 Neueste Beiträge
Well, as with most other doco, Liferay expects that you know something wrt what you're looking at, in this case you already know about log4j.

And although logging changes do not persist across restarts within the control panel, you can create a META-INF/portal-log4j-ext.xml file in LIFERAY_HOME to make sure your logging levels are available across restarts.

Fortunately, the doco is in github and Liferay accepts changes, so feel free to submit whatever changes you feel are appropriate and they'll most likely get included.