Daniele Baggio Vor 11 Jahren In many cases this is necessary, thank you Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen
David García González Vor 11 Jahren I always used the log com.liferay.portal.kernel.log.Log. like this:private static Log logger = LogFactoryUtil.getLog(Clase.class);What is the difference between them and what is the recommended log to log our developed portlets?Thanks. Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen
István Székely Vor 11 Jahren I don't recommend using the ConsoleAppender in production environment at all. It uses the System.out which will be redirected to catalina.out in Tomcat. Since this method does not use the logging facility, this file can't be rotated or compressed. The catalina.out will grow huge very quickly.Unfortunately we have a legacy project which does not use proper logging. In this environment we have to shut down Tomcat every night to rotate and compress the catalina.out file. Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen Kamesh Sampath István Székely Vor 11 Jahren Thanks and good information.@DavidUsing the logger from Liferay API classes has couple of disadvantages 1. It affects portability2.If any chanegs made to the Liferay logging API may have impact on the custom Portlet logging Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen
Kamesh Sampath István Székely Vor 11 Jahren Thanks and good information.@DavidUsing the logger from Liferay API classes has couple of disadvantages 1. It affects portability2.If any chanegs made to the Liferay logging API may have impact on the custom Portlet logging Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen
Brett Swaim Vor 11 Jahren @DavidA lot of people use that, and there really isn't anything wrong with that. There are plusses and minuses to everything.Pros: You can adjust the logging on the fly in the consoleYou are guaranteed future compatibility if Liferay were to ever stop using log4j for some reasonYou don't have to setup anything, it's extremely easy to just log and goCons:Somewhat inflexible configs for storing logs anywhere other than the consoleAs @Kamesh said, it's Liferay specific. I always hear that argument though, and I've yet to actually see somebody go through all the work of building out a system on Liferay, then saying oh never mind and taking all those portlets and moving them to another system. In theory, yes it's Liferay specific, in reality, I've never really seen it matter. Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen
Brett Swaim Vor 11 Jahren @KameshIn regards to your statement 2, that's actually the reason I would say TO use it. You are safe, because you are using our logging system. My worry would be if you are depending on log4j and we change that, THEN you might have issues depending on what was changed. The coolest part about our utils is that we keep you insulated from future changes. Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen Kamesh Sampath Brett Swaim Vor 11 Jahren Thanks Brett, ideally my argument with #2 I agree its a theoriticaly statement but i dont say its not inevitable though i have seen clients doing the same for may portals .. I would rather put this way when you put this way when i use Liferay logger utils then formats of logging , levels are controlled by the Liferay server either i have to use the *-ext mechanisms to override them or use the Liferay admin console. If we tend you use the way said above we are in absolute control of the logging. Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen
Kamesh Sampath Brett Swaim Vor 11 Jahren Thanks Brett, ideally my argument with #2 I agree its a theoriticaly statement but i dont say its not inevitable though i have seen clients doing the same for may portals .. I would rather put this way when you put this way when i use Liferay logger utils then formats of logging , levels are controlled by the Liferay server either i have to use the *-ext mechanisms to override them or use the Liferay admin console. If we tend you use the way said above we are in absolute control of the logging. Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen
Brett Swaim Vor 11 Jahren @IstvánI agree with you in a production environment, but for any other env I love being able to tail just one file and seeing everything fly by. I basically have a monitor dedicated to production logs so I can see if anything happens that shouldn't. I'm not 100% sure how they do it, but the client that I work for has a way to blow away the catalina.out file nightly without bouncing the server. I'll see if I can figure out how today and post it here for you. Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen István Székely Brett Swaim Vor 11 Jahren Thanks, that would be great. Earlier I google'd it but others also said there was no other solution. Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen Brett Swaim István Székely Vor 11 Jahren - Bearbeitet @István They have a cron job that does this (as the deploy user)cat /dev/null > /path/to/liferay/bundles/tomcat-7.0.21/logs/catalina.outI just tested it locally and it worked perfectly. Give it a shot! Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen Remis Baima Brett Swaim Vor 11 Jahren There is one small issue with this approach (at least in 6.0.12 EE). When you use Log4j inside of a ServiceBuilder Impl class (i.e. *LocalServiceImpl.java) you get the Exception described here: http://issues.liferay.com/browse/LPS-9376But anyway... the workaround given in the issue comment will "solve" the problem. Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen Brett Swaim Remis Baima Vor 11 Jahren Right, I actually just ran into that issue myself! I just added:-Dlog4j.ignoreTCL=trueto setenv.sh and that cleaned it up for me. The error this fixes is:log4j:ERROR A "org.apache.log4j.xml.DOMConfigurator" object is not assignable to a "org.apache.log4j.spi.Configurator" variable.log4j:ERROR The class "org.apache.log4j.spi.Configurator" was loaded by log4j:ERROR [WebappClassLoader context: /cisco-webservices-hook delegate: false repositories: /WEB-INF/classes/----------> Parent Classloader:org.apache.catalina.loader.StandardClassLoader@3e4a9a7d] whereas object of type log4j:ERROR "org.apache.log4j.xml.DOMConfigurator" was loaded by [WebappClassLoader context: delegate: false repositories: /WEB-INF/classes/----------> Parent Classloader:org.apache.catalina.loader.StandardClassLoader@3e4a9a7d].log4j:ERROR Could not instantiate configurator [org.apache.log4j.xml.DOMConfigurator]. Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen
István Székely Brett Swaim Vor 11 Jahren Thanks, that would be great. Earlier I google'd it but others also said there was no other solution. Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen Brett Swaim István Székely Vor 11 Jahren - Bearbeitet @István They have a cron job that does this (as the deploy user)cat /dev/null > /path/to/liferay/bundles/tomcat-7.0.21/logs/catalina.outI just tested it locally and it worked perfectly. Give it a shot! Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen Remis Baima Brett Swaim Vor 11 Jahren There is one small issue with this approach (at least in 6.0.12 EE). When you use Log4j inside of a ServiceBuilder Impl class (i.e. *LocalServiceImpl.java) you get the Exception described here: http://issues.liferay.com/browse/LPS-9376But anyway... the workaround given in the issue comment will "solve" the problem. Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen Brett Swaim Remis Baima Vor 11 Jahren Right, I actually just ran into that issue myself! I just added:-Dlog4j.ignoreTCL=trueto setenv.sh and that cleaned it up for me. The error this fixes is:log4j:ERROR A "org.apache.log4j.xml.DOMConfigurator" object is not assignable to a "org.apache.log4j.spi.Configurator" variable.log4j:ERROR The class "org.apache.log4j.spi.Configurator" was loaded by log4j:ERROR [WebappClassLoader context: /cisco-webservices-hook delegate: false repositories: /WEB-INF/classes/----------> Parent Classloader:org.apache.catalina.loader.StandardClassLoader@3e4a9a7d] whereas object of type log4j:ERROR "org.apache.log4j.xml.DOMConfigurator" was loaded by [WebappClassLoader context: delegate: false repositories: /WEB-INF/classes/----------> Parent Classloader:org.apache.catalina.loader.StandardClassLoader@3e4a9a7d].log4j:ERROR Could not instantiate configurator [org.apache.log4j.xml.DOMConfigurator]. Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen
Brett Swaim István Székely Vor 11 Jahren - Bearbeitet @István They have a cron job that does this (as the deploy user)cat /dev/null > /path/to/liferay/bundles/tomcat-7.0.21/logs/catalina.outI just tested it locally and it worked perfectly. Give it a shot! Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen Remis Baima Brett Swaim Vor 11 Jahren There is one small issue with this approach (at least in 6.0.12 EE). When you use Log4j inside of a ServiceBuilder Impl class (i.e. *LocalServiceImpl.java) you get the Exception described here: http://issues.liferay.com/browse/LPS-9376But anyway... the workaround given in the issue comment will "solve" the problem. Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen Brett Swaim Remis Baima Vor 11 Jahren Right, I actually just ran into that issue myself! I just added:-Dlog4j.ignoreTCL=trueto setenv.sh and that cleaned it up for me. The error this fixes is:log4j:ERROR A "org.apache.log4j.xml.DOMConfigurator" object is not assignable to a "org.apache.log4j.spi.Configurator" variable.log4j:ERROR The class "org.apache.log4j.spi.Configurator" was loaded by log4j:ERROR [WebappClassLoader context: /cisco-webservices-hook delegate: false repositories: /WEB-INF/classes/----------> Parent Classloader:org.apache.catalina.loader.StandardClassLoader@3e4a9a7d] whereas object of type log4j:ERROR "org.apache.log4j.xml.DOMConfigurator" was loaded by [WebappClassLoader context: delegate: false repositories: /WEB-INF/classes/----------> Parent Classloader:org.apache.catalina.loader.StandardClassLoader@3e4a9a7d].log4j:ERROR Could not instantiate configurator [org.apache.log4j.xml.DOMConfigurator]. Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen
Remis Baima Brett Swaim Vor 11 Jahren There is one small issue with this approach (at least in 6.0.12 EE). When you use Log4j inside of a ServiceBuilder Impl class (i.e. *LocalServiceImpl.java) you get the Exception described here: http://issues.liferay.com/browse/LPS-9376But anyway... the workaround given in the issue comment will "solve" the problem. Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen Brett Swaim Remis Baima Vor 11 Jahren Right, I actually just ran into that issue myself! I just added:-Dlog4j.ignoreTCL=trueto setenv.sh and that cleaned it up for me. The error this fixes is:log4j:ERROR A "org.apache.log4j.xml.DOMConfigurator" object is not assignable to a "org.apache.log4j.spi.Configurator" variable.log4j:ERROR The class "org.apache.log4j.spi.Configurator" was loaded by log4j:ERROR [WebappClassLoader context: /cisco-webservices-hook delegate: false repositories: /WEB-INF/classes/----------> Parent Classloader:org.apache.catalina.loader.StandardClassLoader@3e4a9a7d] whereas object of type log4j:ERROR "org.apache.log4j.xml.DOMConfigurator" was loaded by [WebappClassLoader context: delegate: false repositories: /WEB-INF/classes/----------> Parent Classloader:org.apache.catalina.loader.StandardClassLoader@3e4a9a7d].log4j:ERROR Could not instantiate configurator [org.apache.log4j.xml.DOMConfigurator]. Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen
Brett Swaim Remis Baima Vor 11 Jahren Right, I actually just ran into that issue myself! I just added:-Dlog4j.ignoreTCL=trueto setenv.sh and that cleaned it up for me. The error this fixes is:log4j:ERROR A "org.apache.log4j.xml.DOMConfigurator" object is not assignable to a "org.apache.log4j.spi.Configurator" variable.log4j:ERROR The class "org.apache.log4j.spi.Configurator" was loaded by log4j:ERROR [WebappClassLoader context: /cisco-webservices-hook delegate: false repositories: /WEB-INF/classes/----------> Parent Classloader:org.apache.catalina.loader.StandardClassLoader@3e4a9a7d] whereas object of type log4j:ERROR "org.apache.log4j.xml.DOMConfigurator" was loaded by [WebappClassLoader context: delegate: false repositories: /WEB-INF/classes/----------> Parent Classloader:org.apache.catalina.loader.StandardClassLoader@3e4a9a7d].log4j:ERROR Could not instantiate configurator [org.apache.log4j.xml.DOMConfigurator]. Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen
Nagendra Kumar Busam Vor 11 Jahren Thanks for sharing, good info Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen
Denis Signoretto Vor 11 Jahren Hi Brett,thanks for your article I found it really useful. Can you explain me why, even though in my sources are not included, after a portlet deployment I found the following log4j and commons-logging related files? (it's a dependecy to get Liferay logging works)?WEB-INF\lib\log4j.jarWEB-INF\lib\commons-logging.jarWEB-INF\classes\log4j.propertiesWEB-INF\classes\logging.propertiesThanks,Denis. Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen Denis Signoretto Denis Signoretto Vor 10 Jahren I answer by myself to my previous question. Duting auto deployment Liferay prepare a new "real" war package that will be deployed to your application server. Auto deployment adds by default portal tld, portal dependecies jar and log4j and common logging jars.If you want to avoid it, from Liferay 6.1, you can disable log4j and common logging using these properties: auto.deploy.copy.log4j=false and auto.deploy.copy.commons.logging=false Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen
Denis Signoretto Denis Signoretto Vor 10 Jahren I answer by myself to my previous question. Duting auto deployment Liferay prepare a new "real" war package that will be deployed to your application server. Auto deployment adds by default portal tld, portal dependecies jar and log4j and common logging jars.If you want to avoid it, from Liferay 6.1, you can disable log4j and common logging using these properties: auto.deploy.copy.log4j=false and auto.deploy.copy.commons.logging=false Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen
Samujjwal Sahu Vor 10 Jahren <rollingPolicy class="org.apache.log4j.rolling.TimeBasedRollingPolicy"> <param name="FileNamePattern" value="../../logs/portlet-name.%d{yyyy-MM-dd}.log" /> </rollingPolicy>The <appender> tag is not accepting this <rollingPolicy> tag in Eclipse. The content of element type "appender" must match "(errorHandler?,param*,layout?,filter*,appender-ref*)".This is the error that it is showing. Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen
Péter Borkuti Vor 10 Jahren Thank you for this info.I have used it for a hook, and worked.Péter Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen
Vishal Srivastava Vor 9 Jahren One of the way is this->-create two files under/tomcat-7.0.40/webapps/ROOT/WEB-INF/classes/META-INF1. portal-log4j-ext.xml <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"> <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"> <appender name="MY_APPENDER" class="org.apache.log4j.RollingFileAppender"> <param name="File" value="${catalina.home}/logs/log_name.log"/> <param name="MaxFileSize" value="10000KB"/> <param name="MaxBackupIndex" value="10"/> <layout class="org.apache.log4j.PatternLayout"> <param name="ConversionPattern" value="----- %n%d{yyyy/MM/dd HH:mm:ss} %p%n%l [%x][%t] %n%m%n" /> </layout> </appender> <root> <priority value="INFO" /> <appender-ref ref="CONSOLE" /> <!-- This being the default appender inside portal-log4j.xml --> <appender-ref ref="MY_APPENDER" /> </root> </log4j:configuration>2. log4j.dtdCopy code from->https://github.com/liferay/liferay-portal/blob/master/portal-impl/test/META-INF/log4j.dtdNote-: creating portal-log4j-ext.xml instead of log4j.xml is best in practice as it override portal-log4j.properties file. Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen
Chirag M Gurav Vor 8 Jahren Hi First of all thanks for such a helpful post,i have implemented log4j in this way and its working fine in for single portlet but when i try same implementation in more then one portlet in same plugin sdk and its not working.for each and every portlet wise logs, is there any other configuration ? Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen Brett Swaim Chirag M Gurav Vor 8 Jahren As long as the portlet name differs in your xml, it should be fine. Do you get any errors or does logging just totally stop working? Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen Chirag M Gurav Brett Swaim Vor 8 Jahren given below error i am getting in console.log4j:ERROR A "org.apache.log4j.xml.DOMConfigurator" object is not assignable to a "org.apache.log4j.spi.Configurator" variable.log4j:ERROR The class "org.apache.log4j.spi.Configurator" was loaded bylog4j:ERROR [WebappClassLoader context: /manage-portlet delegate: false repositories: /WEB-INF/classes/----------> Parent Classloader:org.apache.catalina.loader.StandardClassLoader@53dc5341] whereas object of typelog4j:ERROR "org.apache.log4j.xml.DOMConfigurator" was loaded by [WebappClassLoader context: delegate: false repositories: /WEB-INF/classes/----------> Parent Classloader:org.apache.catalina.loader.StandardClassLoader@53dc5341where i have follow the same steps which you have mention in the blog. Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen
Brett Swaim Chirag M Gurav Vor 8 Jahren As long as the portlet name differs in your xml, it should be fine. Do you get any errors or does logging just totally stop working? Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen Chirag M Gurav Brett Swaim Vor 8 Jahren given below error i am getting in console.log4j:ERROR A "org.apache.log4j.xml.DOMConfigurator" object is not assignable to a "org.apache.log4j.spi.Configurator" variable.log4j:ERROR The class "org.apache.log4j.spi.Configurator" was loaded bylog4j:ERROR [WebappClassLoader context: /manage-portlet delegate: false repositories: /WEB-INF/classes/----------> Parent Classloader:org.apache.catalina.loader.StandardClassLoader@53dc5341] whereas object of typelog4j:ERROR "org.apache.log4j.xml.DOMConfigurator" was loaded by [WebappClassLoader context: delegate: false repositories: /WEB-INF/classes/----------> Parent Classloader:org.apache.catalina.loader.StandardClassLoader@53dc5341where i have follow the same steps which you have mention in the blog. Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen
Chirag M Gurav Brett Swaim Vor 8 Jahren given below error i am getting in console.log4j:ERROR A "org.apache.log4j.xml.DOMConfigurator" object is not assignable to a "org.apache.log4j.spi.Configurator" variable.log4j:ERROR The class "org.apache.log4j.spi.Configurator" was loaded bylog4j:ERROR [WebappClassLoader context: /manage-portlet delegate: false repositories: /WEB-INF/classes/----------> Parent Classloader:org.apache.catalina.loader.StandardClassLoader@53dc5341] whereas object of typelog4j:ERROR "org.apache.log4j.xml.DOMConfigurator" was loaded by [WebappClassLoader context: delegate: false repositories: /WEB-INF/classes/----------> Parent Classloader:org.apache.catalina.loader.StandardClassLoader@53dc5341where i have follow the same steps which you have mention in the blog. Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen