Jan Eerdekens 10 年之前 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. 请登录以投票。 以……回复 取消 Denis Signoretto Jan Eerdekens 10 年之前 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. 请登录以投票。 以……回复 取消 Denis Signoretto Denis Signoretto 10 年之前 As Jan reported in https://issues.liferay.com/browse/LPS-44869 switching to slf4j-log4j12 MDC works as expected. 请登录以投票。 以……回复 取消 Jan Eerdekens Denis Signoretto 10 年之前 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. 请登录以投票。 以……回复 取消 Denis Signoretto Jan Eerdekens 10 年之前 - 编辑过的 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). 请登录以投票。 以……回复 取消
Denis Signoretto Jan Eerdekens 10 年之前 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. 请登录以投票。 以……回复 取消 Denis Signoretto Denis Signoretto 10 年之前 As Jan reported in https://issues.liferay.com/browse/LPS-44869 switching to slf4j-log4j12 MDC works as expected. 请登录以投票。 以……回复 取消 Jan Eerdekens Denis Signoretto 10 年之前 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. 请登录以投票。 以……回复 取消
Denis Signoretto Denis Signoretto 10 年之前 As Jan reported in https://issues.liferay.com/browse/LPS-44869 switching to slf4j-log4j12 MDC works as expected. 请登录以投票。 以……回复 取消
Jan Eerdekens Denis Signoretto 10 年之前 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. 请登录以投票。 以……回复 取消
Denis Signoretto Jan Eerdekens 10 年之前 - 编辑过的 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). 请登录以投票。 以……回复 取消
abdo koptan 9 年之前 Hi Denis, I have follow you steps but it's not working for me, i am using liferay 6.1 - Jboss 7.1Thank you 请登录以投票。 以……回复 取消
Eric Soucy 9 年之前 How would you log from a managedbean in a jsf portlet?what import statements are needed ? 请登录以投票。 以……回复 取消
Eric Soucy 9 年之前 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. 请登录以投票。 以……回复 取消 Denis Signoretto Eric Soucy 9 年之前 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. 请登录以投票。 以……回复 取消
Denis Signoretto Eric Soucy 9 年之前 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. 请登录以投票。 以……回复 取消
Thomas Hii 9 年之前 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? 请登录以投票。 以……回复 取消 Thomas Hii Thomas Hii 9 年之前 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. 请登录以投票。 以……回复 取消 Denis Signoretto Thomas Hii 9 年之前 Hi Tomas,thanks for sharing this info! 请登录以投票。 以……回复 取消
Thomas Hii Thomas Hii 9 年之前 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. 请登录以投票。 以……回复 取消 Denis Signoretto Thomas Hii 9 年之前 Hi Tomas,thanks for sharing this info! 请登录以投票。 以……回复 取消
Alberto de Francisco Martín 8 年之前 Hi, DenisThank you Denis for the information.ThanksAlberto de Francisco 请登录以投票。 以……回复 取消
Nagendra Kumar Busam 8 年之前 Thank you very much sharing details. In your portlet you are using slf4j - where does Liferay's slf4j layer came in? 请登录以投票。 以……回复 取消 Denis Signoretto Nagendra Kumar Busam 8 年之前 Hi Nagendra,Liferay SLF4J layer came in with util-slf4j.jar bridge that implement the slf4j logging adapter for Liferay logging interface. 请登录以投票。 以……回复 取消
Denis Signoretto Nagendra Kumar Busam 8 年之前 Hi Nagendra,Liferay SLF4J layer came in with util-slf4j.jar bridge that implement the slf4j logging adapter for Liferay logging interface. 请登录以投票。 以……回复 取消
parikshit sharma 8 年之前 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 请登录以投票。 以……回复 取消
sandeep g 8 年之前 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> 请登录以投票。 以……回复 取消