Jan Eerdekens Vor 10 Jahren 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. Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen Denis Signoretto Jan Eerdekens Vor 10 Jahren 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. Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen Denis Signoretto Denis Signoretto Vor 10 Jahren As Jan reported in https://issues.liferay.com/browse/LPS-44869 switching to slf4j-log4j12 MDC works as expected. Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen Jan Eerdekens Denis Signoretto Vor 10 Jahren 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. Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen Denis Signoretto Jan Eerdekens Vor 10 Jahren - Bearbeitet 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). Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen
Denis Signoretto Jan Eerdekens Vor 10 Jahren 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. Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen Denis Signoretto Denis Signoretto Vor 10 Jahren As Jan reported in https://issues.liferay.com/browse/LPS-44869 switching to slf4j-log4j12 MDC works as expected. Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen Jan Eerdekens Denis Signoretto Vor 10 Jahren 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. Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen
Denis Signoretto Denis Signoretto Vor 10 Jahren As Jan reported in https://issues.liferay.com/browse/LPS-44869 switching to slf4j-log4j12 MDC works as expected. Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen
Jan Eerdekens Denis Signoretto Vor 10 Jahren 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. Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen
Denis Signoretto Jan Eerdekens Vor 10 Jahren - Bearbeitet 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). Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen
abdo koptan Vor 9 Jahren Hi Denis, I have follow you steps but it's not working for me, i am using liferay 6.1 - Jboss 7.1Thank you Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen
Eric Soucy Vor 9 Jahren How would you log from a managedbean in a jsf portlet?what import statements are needed ? Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen
Eric Soucy Vor 9 Jahren 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. Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen Denis Signoretto Eric Soucy Vor 9 Jahren 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. Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen
Denis Signoretto Eric Soucy Vor 9 Jahren 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. Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen
Thomas Hii Vor 9 Jahren 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? Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen Thomas Hii Thomas Hii Vor 9 Jahren 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. Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen Denis Signoretto Thomas Hii Vor 9 Jahren Hi Tomas,thanks for sharing this info! Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen
Thomas Hii Thomas Hii Vor 9 Jahren 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. Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen Denis Signoretto Thomas Hii Vor 9 Jahren Hi Tomas,thanks for sharing this info! Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen
Denis Signoretto Thomas Hii Vor 9 Jahren Hi Tomas,thanks for sharing this info! Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen
Alberto de Francisco Martín Vor 8 Jahren Hi, DenisThank you Denis for the information.ThanksAlberto de Francisco Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen
Nagendra Kumar Busam Vor 8 Jahren Thank you very much sharing details. In your portlet you are using slf4j - where does Liferay's slf4j layer came in? Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen Denis Signoretto Nagendra Kumar Busam Vor 8 Jahren Hi Nagendra,Liferay SLF4J layer came in with util-slf4j.jar bridge that implement the slf4j logging adapter for Liferay logging interface. Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen
Denis Signoretto Nagendra Kumar Busam Vor 8 Jahren Hi Nagendra,Liferay SLF4J layer came in with util-slf4j.jar bridge that implement the slf4j logging adapter for Liferay logging interface. Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen
parikshit sharma Vor 8 Jahren 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 Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen
sandeep g Vor 8 Jahren 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> Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen