Daniele Baggio Hace 11 años In many cases this is necessary, thank you Por favor identifíquese para votar. Contestar como... Cancelar
David García González Hace 11 años 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. Por favor identifíquese para votar. Contestar como... Cancelar
István Székely Hace 11 años 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. Por favor identifíquese para votar. Contestar como... Cancelar Kamesh Sampath István Székely Hace 11 años 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 Por favor identifíquese para votar. Contestar como... Cancelar
Kamesh Sampath István Székely Hace 11 años 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 Por favor identifíquese para votar. Contestar como... Cancelar
Brett Swaim Hace 11 años @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. Por favor identifíquese para votar. Contestar como... Cancelar
Brett Swaim Hace 11 años @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. Por favor identifíquese para votar. Contestar como... Cancelar Kamesh Sampath Brett Swaim Hace 11 años 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. Por favor identifíquese para votar. Contestar como... Cancelar
Kamesh Sampath Brett Swaim Hace 11 años 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. Por favor identifíquese para votar. Contestar como... Cancelar
Brett Swaim Hace 11 años @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. Por favor identifíquese para votar. Contestar como... Cancelar István Székely Brett Swaim Hace 11 años Thanks, that would be great. Earlier I google'd it but others also said there was no other solution. Por favor identifíquese para votar. Contestar como... Cancelar Brett Swaim István Székely Hace 11 años - Editado @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! Por favor identifíquese para votar. Contestar como... Cancelar Remis Baima Brett Swaim Hace 11 años 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. Por favor identifíquese para votar. Contestar como... Cancelar Brett Swaim Remis Baima Hace 11 años 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]. Por favor identifíquese para votar. Contestar como... Cancelar
István Székely Brett Swaim Hace 11 años Thanks, that would be great. Earlier I google'd it but others also said there was no other solution. Por favor identifíquese para votar. Contestar como... Cancelar Brett Swaim István Székely Hace 11 años - Editado @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! Por favor identifíquese para votar. Contestar como... Cancelar Remis Baima Brett Swaim Hace 11 años 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. Por favor identifíquese para votar. Contestar como... Cancelar Brett Swaim Remis Baima Hace 11 años 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]. Por favor identifíquese para votar. Contestar como... Cancelar
Brett Swaim István Székely Hace 11 años - Editado @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! Por favor identifíquese para votar. Contestar como... Cancelar Remis Baima Brett Swaim Hace 11 años 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. Por favor identifíquese para votar. Contestar como... Cancelar Brett Swaim Remis Baima Hace 11 años 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]. Por favor identifíquese para votar. Contestar como... Cancelar
Remis Baima Brett Swaim Hace 11 años 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. Por favor identifíquese para votar. Contestar como... Cancelar Brett Swaim Remis Baima Hace 11 años 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]. Por favor identifíquese para votar. Contestar como... Cancelar
Brett Swaim Remis Baima Hace 11 años 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]. Por favor identifíquese para votar. Contestar como... Cancelar
Nagendra Kumar Busam Hace 11 años Thanks for sharing, good info Por favor identifíquese para votar. Contestar como... Cancelar
Denis Signoretto Hace 11 años 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. Por favor identifíquese para votar. Contestar como... Cancelar Denis Signoretto Denis Signoretto Hace 10 años 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 Por favor identifíquese para votar. Contestar como... Cancelar
Denis Signoretto Denis Signoretto Hace 10 años 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 Por favor identifíquese para votar. Contestar como... Cancelar
Samujjwal Sahu Hace 10 años <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. Por favor identifíquese para votar. Contestar como... Cancelar
Péter Borkuti Hace 10 años Thank you for this info.I have used it for a hook, and worked.Péter Por favor identifíquese para votar. Contestar como... Cancelar
Vishal Srivastava Hace 9 años 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. Por favor identifíquese para votar. Contestar como... Cancelar
Chirag M Gurav Hace 8 años 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 ? Por favor identifíquese para votar. Contestar como... Cancelar Brett Swaim Chirag M Gurav Hace 8 años 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? Por favor identifíquese para votar. Contestar como... Cancelar Chirag M Gurav Brett Swaim Hace 8 años 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. Por favor identifíquese para votar. Contestar como... Cancelar
Brett Swaim Chirag M Gurav Hace 8 años 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? Por favor identifíquese para votar. Contestar como... Cancelar Chirag M Gurav Brett Swaim Hace 8 años 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. Por favor identifíquese para votar. Contestar como... Cancelar
Chirag M Gurav Brett Swaim Hace 8 años 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. Por favor identifíquese para votar. Contestar como... Cancelar