Jan Eerdekens Hace 10 años I got this to work for the most part, but can't seem to get MDC to work. I add values to the MDC and use a pattern that should print them, but no values get printed, but the rest of the log line does. Por favor identifíquese para votar. Contestar como... Cancelar Denis Signoretto Jan Eerdekens Hace 10 años Hi Jan,happy to hear that you tryied and it works. I can confirm that MDC(Mapped Diagnostic Context) doesn't work using Liferay Logging Framework SLF4J Adapter (util-slf4j.jar). Looking at source code of org.slf4j.impl.StaticMDCBinder (https://github.com/liferay/liferay-portal/blob/6.2.0-ga1/util-slf4j/src/org/slf4j/impl/StaticMDCBinder.java) it returns a BasicMDCAdapter and as BasicMDCAdapter javadoc reports "can be used with logging systems that lack out-of-the-box MDC support". It seems it's still an unsupported feature.I've just seen, commented and voted your reported https://issues.liferay.com/browse/LPS-44869. Thanks,Denis. Por favor identifíquese para votar. Contestar como... Cancelar Denis Signoretto Denis Signoretto Hace 10 años As Jan reported in https://issues.liferay.com/browse/LPS-44869 switching to slf4j-log4j12 MDC works as expected. Por favor identifíquese para votar. Contestar como... Cancelar Jan Eerdekens Denis Signoretto Hace 10 años I tried some (very) quick debugging yesterday and found that stuff got put into the MDC correctly, but when the log message is being formatted the values aren't there anymore. Didn't have the time yet to delve in deeper to see what causes it. Por favor identifíquese para votar. Contestar como... Cancelar Denis Signoretto Jan Eerdekens Hace 10 años - Editado I opened a feature request to add MDC (Mapped Diagnostic Context) support to Liferay Logging API (https://issues.liferay.com/browse/LPS-44900) and extend it to SLF4J Adapter (https://issues.liferay.com/browse/LPS-44869). Por favor identifíquese para votar. Contestar como... Cancelar
Denis Signoretto Jan Eerdekens Hace 10 años Hi Jan,happy to hear that you tryied and it works. I can confirm that MDC(Mapped Diagnostic Context) doesn't work using Liferay Logging Framework SLF4J Adapter (util-slf4j.jar). Looking at source code of org.slf4j.impl.StaticMDCBinder (https://github.com/liferay/liferay-portal/blob/6.2.0-ga1/util-slf4j/src/org/slf4j/impl/StaticMDCBinder.java) it returns a BasicMDCAdapter and as BasicMDCAdapter javadoc reports "can be used with logging systems that lack out-of-the-box MDC support". It seems it's still an unsupported feature.I've just seen, commented and voted your reported https://issues.liferay.com/browse/LPS-44869. Thanks,Denis. Por favor identifíquese para votar. Contestar como... Cancelar Denis Signoretto Denis Signoretto Hace 10 años As Jan reported in https://issues.liferay.com/browse/LPS-44869 switching to slf4j-log4j12 MDC works as expected. Por favor identifíquese para votar. Contestar como... Cancelar Jan Eerdekens Denis Signoretto Hace 10 años I tried some (very) quick debugging yesterday and found that stuff got put into the MDC correctly, but when the log message is being formatted the values aren't there anymore. Didn't have the time yet to delve in deeper to see what causes it. Por favor identifíquese para votar. Contestar como... Cancelar
Denis Signoretto Denis Signoretto Hace 10 años As Jan reported in https://issues.liferay.com/browse/LPS-44869 switching to slf4j-log4j12 MDC works as expected. Por favor identifíquese para votar. Contestar como... Cancelar
Jan Eerdekens Denis Signoretto Hace 10 años I tried some (very) quick debugging yesterday and found that stuff got put into the MDC correctly, but when the log message is being formatted the values aren't there anymore. Didn't have the time yet to delve in deeper to see what causes it. Por favor identifíquese para votar. Contestar como... Cancelar
Denis Signoretto Jan Eerdekens Hace 10 años - Editado I opened a feature request to add MDC (Mapped Diagnostic Context) support to Liferay Logging API (https://issues.liferay.com/browse/LPS-44900) and extend it to SLF4J Adapter (https://issues.liferay.com/browse/LPS-44869). Por favor identifíquese para votar. Contestar como... Cancelar
abdo koptan Hace 9 años Hi Denis, I have follow you steps but it's not working for me, i am using liferay 6.1 - Jboss 7.1Thank you Por favor identifíquese para votar. Contestar como... Cancelar
Eric Soucy Hace 9 años How would you log from a managedbean in a jsf portlet?what import statements are needed ? Por favor identifíquese para votar. Contestar como... Cancelar
Eric Soucy Hace 9 años Hi,It's working partially for me, I see my log output in the console, and in the liferay.log filemy custom rolling appender file gets created but my logout output is not in the file.I do see other lines being logged in the file, but not the ones I logged from my managed bean. Por favor identifíquese para votar. Contestar como... Cancelar Denis Signoretto Eric Soucy Hace 9 años Hi Eric,it seems, you have setup correclty the Liferay logging system to log on a separate file but you are not sending log to Liferay logging system. Check your slf4j imports in your class and use an slf4j Logger instance for logging.import org.slf4j.Logger;import org.slf4j.LoggerFactory;You can find a working slf4j sample portlet here: https://github.com/denissignoretto/slf4j-logging-sample-portletHope it can help!Denis. Por favor identifíquese para votar. Contestar como... Cancelar
Denis Signoretto Eric Soucy Hace 9 años Hi Eric,it seems, you have setup correclty the Liferay logging system to log on a separate file but you are not sending log to Liferay logging system. Check your slf4j imports in your class and use an slf4j Logger instance for logging.import org.slf4j.Logger;import org.slf4j.LoggerFactory;You can find a working slf4j sample portlet here: https://github.com/denissignoretto/slf4j-logging-sample-portletHope it can help!Denis. Por favor identifíquese para votar. Contestar como... Cancelar
Thomas Hii Hace 9 años Hi Denis,The example is working great for Liferay 6.2 running on Tomcat. However when I tried it with Liferay 6.2 running on JBoss 7 or JBoss EAP 6, the log file is created but nothing is written to it. Any idea on what might cause this problem? Por favor identifíquese para votar. Contestar como... Cancelar Thomas Hii Thomas Hii Hace 9 años Finally figured out that the problem is due to JBoss class loading. By default, JBoss always load its version of log4j and slf4j. These need to be excluded via the jboss-deployment-structure.xml file. App Manager seems to generate this file during deployment, but org.slf4j is not in the exclusion list. After adding org.slf4j, the custom logging works nicely on JBoss 7.1 and JBoss EAP 6.2. Por favor identifíquese para votar. Contestar como... Cancelar Denis Signoretto Thomas Hii Hace 9 años Hi Tomas,thanks for sharing this info! Por favor identifíquese para votar. Contestar como... Cancelar
Thomas Hii Thomas Hii Hace 9 años Finally figured out that the problem is due to JBoss class loading. By default, JBoss always load its version of log4j and slf4j. These need to be excluded via the jboss-deployment-structure.xml file. App Manager seems to generate this file during deployment, but org.slf4j is not in the exclusion list. After adding org.slf4j, the custom logging works nicely on JBoss 7.1 and JBoss EAP 6.2. Por favor identifíquese para votar. Contestar como... Cancelar Denis Signoretto Thomas Hii Hace 9 años Hi Tomas,thanks for sharing this info! Por favor identifíquese para votar. Contestar como... Cancelar
Denis Signoretto Thomas Hii Hace 9 años Hi Tomas,thanks for sharing this info! Por favor identifíquese para votar. Contestar como... Cancelar
Alberto de Francisco Martín Hace 8 años Hi, DenisThank you Denis for the information.ThanksAlberto de Francisco Por favor identifíquese para votar. Contestar como... Cancelar
Nagendra Kumar Busam Hace 8 años Thank you very much sharing details. In your portlet you are using slf4j - where does Liferay's slf4j layer came in? Por favor identifíquese para votar. Contestar como... Cancelar Denis Signoretto Nagendra Kumar Busam Hace 8 años Hi Nagendra,Liferay SLF4J layer came in with util-slf4j.jar bridge that implement the slf4j logging adapter for Liferay logging interface. Por favor identifíquese para votar. Contestar como... Cancelar
Denis Signoretto Nagendra Kumar Busam Hace 8 años Hi Nagendra,Liferay SLF4J layer came in with util-slf4j.jar bridge that implement the slf4j logging adapter for Liferay logging interface. Por favor identifíquese para votar. Contestar como... Cancelar
parikshit sharma Hace 8 años Hi Denis,As per your blog I am trying to implement the logs for custom portlet on bundled JBOSS server 7.1.1, but it's generating the blank log file, could you please guide me what I am missing. Below are the configurations I have done to implement it.1.Added the dependencies for slf4j-api.jar and util-slf4j.jar file in pom.xml.2.If I add the log4j.jar dependency in pom.xml , at the time of deployment it raise below exception. java.lang.ClassCastException: org.apache.log4j.EnhancedPatternLayout cannot be cast to org.apache.log4j.LayoutI searched for it , and found that by adding the log4j.jar in portlet I am initializing it again, as it is already initialized by JBOSS. So I added below configurationAdded jboss-deployment-structure.xml ,with below configuration <exclusions> <module name="javaee.api"></module> <module name="org.apache.log4j"></module> <module name="org.slf4j"></module> <module name="org.slf4j.impl"></module> <module name="org.jboss.logging"></module> <module name="org.jboss.logging.jul-to-slf4j-stub"></module> <module name="org.jboss.logmanager"></module> <module name="org.jboss.logmanager.log4j"></module> </exclusions>But still it raise the same exception.Thanks.Parikshit Por favor identifíquese para votar. Contestar como... Cancelar
sandeep g Hace 8 años It is also not working for me on jboss EAP 6.2. I have excluded all the modules still no luck.<exclusions> <module name="javaee.api" /> <module name="org.apache.log4j" /> <module name="org.apache.commons.logging" /> <module name="org.jboss.logging" /> <module name="org.jboss.logging.jul-to-slf4j-stub" /> <module name="org.jboss.logmanager" /> <module name="org.jboss.logmanager.log4j" /> <module name="org.slf4j" /> <module name="org.slf4j.impl" /> </exclusions> Por favor identifíquese para votar. Contestar como... Cancelar