Foren

Log4j Configuration

thumbnail
Heri Bender, geändert vor 9 Jahren.

Log4j Configuration

New Member Beiträge: 12 Beitrittsdatum: 11.02.14 Neueste Beiträge
I'm still learning liferay ( version 6.2).

Again and again something goes not the way I imagine it. But for the analysis of an error I only have the (often unhelpful ) error message displayed online ( "Your request failed to complete" or similar).

catalina.log and the log4j (own setup, see below) log files report mostly nothing about the just happened error.
Log4j and Liferay is quite a mystery to me. The usual mechanisms of Log4j are not working (auto-configuration from a log4j.xml file in the classpath, command line option -Dlog4j.debug=true has no effect, etc.) I have learned in other posts that a separate portal-log4j-ext.xml file must be placed in a <classpath>/META -INF/ directory, which I did in tomcat/lib/WEB-INF.

The configured log-file is indeed created in root/logs where I expect it (what prooves that the config file is picked up). But the information it contains are very sparse. Actually, just stuff that doesn't interested me at the moment, like rendering times, etc. If the frontend displays an error message, then - I guess - an Exception must have happened somewhere. But I cannot find any entry on WARN or ERROR level.

Personally, I am a Java developer and actually quite experienced to log4j, but I do not really understand how this tool is used by Liferay. For example :
- What should the Java Util command-line param in the startup script? Since I have log4j?
- The same with the repetitions in each portlet's logging.properties which all log to a console (which is not really present on a server) .

When I step through a system start in the debugger, I see that first the Java Logging is initialized. The initialized Logger classes are completely encapsulated by a LR-own log Adapter Framework (with a similar interface as commons-logging). In the further course log4j is also loaded. It seems that at this point the entire encapsulated Logger instances are replaced by Log4j implementations. From this point on, log entries appear in my configured DailyRollingFileAppender. But I suspect that only a small part of the log statements issued by LR find the way to my log file.

In the wiki's and the various guides (User, Admin, Developer) is almost nothing to be found about the logging, and what's there, is - in some cases - only half true, at least pretty useless.

I'd like to find all relevant log entries in _one_ file (from _all_ portlets and core, especially the errors), from the startup. How to set up log4j to achieve this?