-
15. Re: Logback JBoss 7
jamezp Mar 14, 2013 7:31 PM (in response to klind)Trial by fire! :-) You should need to add those. Try adding a module for javax.api. The SAX parsers are in there.
--
James R. Perkins
-
16. Re: Logback JBoss 7
klind Mar 14, 2013 8:41 PM (in response to klind)I took a few steps back.....
Deleted custom module :
<module name="ch.qos.logback" />
<module name="org.slf4j" slot="1.7.2"/>
Provide logback and slf4j in the ear/lib.
Exclude all the jboss slf4j stuff....
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.0"> <ear-subdeployments-isolated>false</ear-subdeployments-isolated> <deployment> <exclusions> <!-- Exclude hibernate as we use the latest hibenate that we provide. see JSI/pom.xml --> <module name="org.hibernate" /> <module name="org.hibernate.validator" /> <!-- Exclude slf4j 1.6.1, we provide 1.7.2 --> <module name="org.apache.commons.logging" /> <module name="org.slf4j" /> <module name="org.slf4j.ext" /> <module name="org.slf4j.jcl-over-slf4j" /> <!-- Exclude slf4j-jboss-logmanager --> <module name="org.slf4j.impl" /> <module name="org.apache.log4j" /> </exclusions> </deployment> <sub-deployment name="dashboard.war"> <exclusions> <!-- Exclude hibernate as we use the latest hibenate that we provide. see JSI/pom.xml --> <module name="org.hibernate" /> <module name="org.hibernate.validator" /> <!-- Exclude slf4j 1.6.1, we provide 1.7.2 --> <module name="org.apache.commons.logging" /> <module name="org.slf4j" /> <module name="org.slf4j.ext" /> <module name="org.slf4j.jcl-over-slf4j" /> <!-- Exclude slf4j-jboss-logmanager --> <module name="org.slf4j.impl" /> <module name="org.apache.log4j" /> </exclusions> </sub-deployment> <sub-deployment name="profitMock.war"> <exclusions> <!-- Exclude hibernate as we use the latest hibenate that we provide. see JSI/pom.xml --> <module name="org.hibernate" /> <module name="org.hibernate.validator" /> <!-- Exclude slf4j 1.6.1, we provide 1.7.2 --> <module name="org.apache.commons.logging" /> <module name="org.slf4j" /> <module name="org.slf4j.ext" /> <module name="org.slf4j.jcl-over-slf4j" /> <!-- Exclude slf4j-jboss-logmanager --> <module name="org.slf4j.impl" /> <module name="org.apache.log4j" /> </exclusions> </sub-deployment> </jboss-deployment-structure>
And now I see this in the log...
17:33:26,374 INFO [stdout] (MSC service thread 1-1) 17:33:26,320 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - Setting ReconfigureOnChangeFilter scanning period to 30 seconds 17:33:26,378 INFO [stdout] (MSC service thread 1-1) 17:33:26,378 |-INFO in ReconfigureOnChangeFilter{invocationCounter=0} - Will scan for changes in [[C:\jboss\bin\..\standalone\configuration\logback.xml]] every 30 seconds. 17:33:26,381 INFO [stdout] (MSC service thread 1-1) 17:33:26,381 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - Adding ReconfigureOnChangeFilter as a turbo filter 17:33:26,403 INFO [stdout] (MSC service thread 1-1) 17:33:26,403 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.ConsoleAppender] 17:33:26,512 INFO [stdout] (MSC service thread 1-1) 17:33:26,512 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [CONSOLE] 17:33:27,045 INFO [stdout] (MSC service thread 1-1) 17:33:27,045 |-INFO in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Assuming default type [ch.qos.logback.classic.encoder.PatternLayoutEncoder] for [encoder] property 17:33:28,653 INFO [stdout] (MSC service thread 1-1) 17:33:28,653 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.rolling.RollingFileAppender] 17:33:28,756 INFO [stdout] (MSC service thread 1-1) 17:33:28,756 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [FILE] 17:33:29,343 INFO [stdout] (MSC service thread 1-1) 17:33:29,343 |-INFO in c.q.l.core.rolling.TimeBasedRollingPolicy - No compression will be used 17:33:29,380 INFO [stdout] (MSC service thread 1-1) 17:33:29,380 |-INFO in c.q.l.core.rolling.TimeBasedRollingPolicy - Will use the pattern logFile.%d{yyyy-MM-dd}.log for the active file 17:33:29,491 INFO [stdout] (MSC service thread 1-1) 17:33:29,491 |-INFO in c.q.l.core.rolling.DefaultTimeBasedFileNamingAndTriggeringPolicy - The date patternis 'yyyy-MM-dd' from file name pattern 'logFile.%d{yyyy-MM-dd}.log'. 17:33:29,495 INFO [stdout] (MSC service thread 1-1) 17:33:29,495 |-INFO in c.q.l.core.rolling.DefaultTimeBasedFileNamingAndTriggeringPolicy - Roll-over at midnight. 17:33:29,498 INFO [stdout] (MSC service thread 1-1) 17:33:29,498 |-INFO in c.q.l.core.rolling.DefaultTimeBasedFileNamingAndTriggeringPolicy - Setting initial period to Thu Mar 14 17:08:52 PDT 2013 17:33:29,536 INFO [stdout] (MSC service thread 1-1) 17:33:29,536 |-INFO in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Assuming default type [ch.qos.logback.classic.encoder.PatternLayoutEncoder] for [encoder] property 17:33:29,540 INFO [stdout] (MSC service thread 1-1) 17:33:29,540 |-INFO in ch.qos.logback.core.rolling.RollingFileAppender[FILE] - Active log file name: /log/jsi.log 17:33:29,543 INFO [stdout] (MSC service thread 1-1) 17:33:29,543 |-INFO in ch.qos.logback.core.rolling.RollingFileAppender[FILE] - File property is set to [/log/jsi.log] 17:33:29,563 INFO [stdout] (MSC service thread 1-1) 17:33:29,563 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.classic.net.SMTPAppender] 17:33:29,793 INFO [stdout] (MSC service thread 1-1) 17:33:29,792 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [MAIL] 17:33:30,284 INFO [stdout] (MSC service thread 1-1) 17:33:30,284 |-INFO in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Assuming default type [ch.qos.logback.classic.PatternLayout] for [layout] property 17:33:30,719 INFO [stdout] (MSC service thread 1-1) 17:33:30,719 |-INFO in ch.qos.logback.classic.joran.action.RootLoggerAction - Setting level of ROOT loggerto INFO 17:33:30,722 INFO [stdout] (MSC service thread 1-1) 17:33:30,722 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [CONSOLE] to Logger[ROOT] 17:33:30,743 INFO [stdout] (MSC service thread 1-1) 17:33:30,743 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [FILE] to Logger[ROOT] 17:33:30,746 INFO [stdout] (MSC service thread 1-1) 17:33:30,746 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [MAIL] to Logger[ROOT] 17:33:30,767 INFO [stdout] (MSC service thread 1-1) 17:33:30,767 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [com.farheap.jsi.profitmock] to DEBUG 17:33:30,771 INFO [stdout] (MSC service thread 1-1) 17:33:30,771 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - End of configuration. 17:33:30,808 INFO [stdout] (MSC service thread 1-1) 17:33:30,808 |-INFO in ch.qos.logback.classic.joran.JoranConfigurator@41c03bfe - Registering current configuration as safe fallback point
So now the logback is found and the logback.xml is also found....
but but..
17:33:30,833 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-1) MSC00001: Failed to start service jboss.deployment.subunit."jsi-3.30.2-SNAPSHOT.ear"."p rofitMock.war".INSTALL: org.jboss.msc.service.StartException in service jboss.deployment.subunit."jsi-3.30.2-SNAPSHOT.ear"."profitMock.war".INSTALL: Failed to p rocess phase INSTALL of subdeployment "profitMock.war" of deployment "jsi-3.30.2-SNAPSHOT.ear" at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:119) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final] at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA.jar:1.0.2.GA] at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA.jar:1.0.2.GA] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_13] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_13] at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0_13] Caused by: java.lang.LinkageError: loader constraint violation: when resolving method "org.slf4j.impl.StaticLoggerBinder.getLoggerFactory()Lorg/slf4j/ILoggerFac tory;" the class loader (instance of org/jboss/modules/ModuleClassLoader) of the current class, org/slf4j/LoggerFactory, and the class loader (instance of org/j boss/modules/ModuleClassLoader) for resolved class, org/slf4j/impl/StaticLoggerBinder, have different Class objects for the type LoggerFactory; used in the sign ature at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:299) at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:269) at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:281) at com.farheap.jsi.profitmock.ProfitMockSoap.<clinit>(ProfitMockSoap.java:18) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) [rt.jar:1.7.0_13] at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) [rt.jar:1.7.0_13] at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) [rt.jar:1.7.0_13] at java.lang.reflect.Constructor.newInstance(Constructor.java:525) [rt.jar:1.7.0_13] at java.lang.Class.newInstance0(Class.java:374) [rt.jar:1.7.0_13] at java.lang.Class.newInstance(Class.java:327) [rt.jar:1.7.0_13] at org.jboss.wsf.stack.cxf.configuration.NonSpringBusHolder.newInstance(NonSpringBusHolder.java:170) at org.jboss.wsf.stack.cxf.configuration.NonSpringBusHolder.configure(NonSpringBusHolder.java:96) at org.jboss.wsf.stack.cxf.deployment.aspect.BusDeploymentAspect.startDeploymentBus(BusDeploymentAspect.java:113) at org.jboss.wsf.stack.cxf.deployment.aspect.BusDeploymentAspect.start(BusDeploymentAspect.java:66) at org.jboss.as.webservices.deployers.AspectDeploymentProcessor.deploy(AspectDeploymentProcessor.java:74) at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:113) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final] ... 5 more
I looks to me like the exclusion of the jboss slf4j is not working...
-
17. Re: Logback JBoss 7
klind Mar 14, 2013 8:59 PM (in response to jamezp)When adding javax.api i just get
17:57:48,479 INFO [stdout] (MSC service thread 1-2) Caused by: java.lang.NoClassDefFoundError: javax/mail/Authenticator
17:57:48,482 INFO [stdout] (MSC service thread 1-2) at at java.lang.Class.getDeclaredConstructors0(Native Method)
17:57:48,485 INFO [stdout] (MSC service thread 1-2) at at java.lang.Class.privateGetDeclaredConstructors(Class.java:2413)
17:57:48,488 INFO [stdout] (MSC service thread 1-2) at at java.lang.Class.getConstructor0(Class.java:2723)
And I guess I could get going until there is no more errors... But that is not what I want
-
18. Re: Logback JBoss 7
jamezp Mar 15, 2013 2:01 PM (in response to klind)Well that doesn't make much sense. It seems you're explicitly excluding the dependencies from the subdeployments which is required.
What version of JBoss AS 7?
--
James R. Perkins
-
19. Re: Logback JBoss 7
klind Mar 15, 2013 4:51 PM (in response to jamezp)JBoss 7.1.1 final.
But I got it to work now
Custom slf4j 1.7.3 module
<?xml version="1.0" encoding="UTF-8"?> <module xmlns="urn:jboss:module:1.1" name="org.slf4j" slot="1.7.3"> <resources> <resource-root path="slf4j-api-1.7.3.jar"/> </resources> <dependencies> <module name="ch.qos.logback" /> </dependencies> </module>
Custom logback 1.0.9 module
<?xml version="1.0" encoding="UTF-8"?> <module xmlns="urn:jboss:module:1.1" name="ch.qos.logback"> <resources> <resource-root path="logback-classic-1.0.9.jar"/> <resource-root path="logback-core-1.0.9.jar"/> </resources> <dependencies> <module name="org.slf4j" slot="1.7.3" /> <module name="javax.api" /> <module name="javax.mail.api" /> </dependencies> </module>
Standalone.bat
Set LOGBACK_CONF_FILE=-Dlogback.configurationFile=%JBOSS_BASE_DIR%/configuration/logback.xml "%JAVA%" %JAVA_OPTS% ^ "-Dorg.jboss.boot.log.file=%JBOSS_LOG_DIR%\boot.log" ^ "-Dlogging.configuration=file:%JBOSS_CONFIG_DIR%/logging.properties" ^ -jar "%JBOSS_HOME%\jboss-modules.jar" ^ -mp "%JBOSS_MODULEPATH%" ^ -jaxpmodule "javax.xml.jaxp-provider" ^ org.jboss.as.standalone ^ -Djboss.home.dir="%JBOSS_HOME%" ^ %LOGBACK_CONF_FILE% ^ %*
logback.xml is placed in
jboss\standalone\configuration
jboss-deployment-structure.xml
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.0"> <ear-subdeployments-isolated>false</ear-subdeployments-isolated> <deployment> <exclusions> <!-- Exclude slf4j 1.6.1, we added new module in jboss with 1.7.3 --> <module name="org.apache.commons.logging" /> <module name="org.slf4j" /> <module name="org.slf4j.ext" /> <module name="org.slf4j.jcl-over-slf4j" /> <!-- Exclude slf4j-jboss-logmanager, we want to use logback that we added as a module --> <module name="org.slf4j.impl" /> <module name="org.apache.log4j" /> </exclusions> <dependencies> <!-- add our own modules --> <module name="ch.qos.logback" /> <module name="org.slf4j" slot="1.7.3"/> </dependencies> </deployment> <sub-deployment name="dashboard.war"> <exclusions> <module name="org.apache.commons.logging" /> <module name="org.slf4j" /> <module name="org.slf4j.ext" /> <module name="org.slf4j.jcl-over-slf4j" /> <module name="org.slf4j.impl" /> <module name="org.apache.log4j" /> </exclusions> <dependencies> <module name="ch.qos.logback" /> <module name="org.slf4j" slot="1.7.3"/> </dependencies> </sub-deployment> <sub-deployment name="profitMock.war"> <exclusions> <module name="org.apache.commons.logging" /> <module name="org.slf4j" /> <module name="org.slf4j.ext" /> <module name="org.slf4j.jcl-over-slf4j" /> <module name="org.slf4j.impl" /> <module name="org.apache.log4j" /> </exclusions> <dependencies> <module name="ch.qos.logback" /> <module name="org.slf4j" slot="1.7.3"/> </dependencies> </sub-deployment> </jboss-deployment-structure>
The log is created on startup and log is written to the file.
I guess I could run into some problems with missing classes in logback, and would then have to add them as dependencies in logback module.xml
And slf4j and logback has scope provided in pom.xml
-
20. Re: Logback JBoss 7
jamezp Mar 15, 2013 4:53 PM (in response to klind)Woohoo! Glad you got it sorted out.
--
James R. Perkins
-
21. Re: Logback JBoss 7
jamezp Mar 15, 2013 5:49 PM (in response to klind)I should have mentioned this earlier, but in the EAP 6 alpha that is now available for download you can use log4j appenders as custom-handler's. I just completely forgot about for some reason :-)
--
James R. Perkins
-
22. Re: Logback JBoss 7
klind Mar 26, 2013 8:22 PM (in response to jamezp)For now the AS is good.. don't know if my CEO will spend the money on EAP
But thanks for help on this issue.
The only thing outstanding is that there might be a bug with the module exclusion.
see
16. Mar 14, 2013 8:41 PM (in response to klind)
-
23. Re: Logback JBoss 7
jamezp Mar 16, 2013 4:29 PM (in response to klind)You can get Alpha's of EAP with a $0 subscription. You can get more information from Mark Little's blog post about it, https://community.jboss.org/blogs/mark.little/2013/03/07/eap-binaries-available-for-all-developers. You can download it here http://www.jboss.org/jbossas/downloads/ The FAQ supports that since it's LGPL you can run it in production as well.
There have been some bugs in the module exclusion that are fixed in the 7.2.0.Final tag and at the EAP 6.1 Alpha that's available for download. I'm not sure if you want to build from source or could use the EAP Alpha, but it might resolve these issues.
--
James R. Perkins
-
24. Re: Logback JBoss 7
klind Apr 30, 2013 1:51 PM (in response to klind)Have to open this question again... I am having some problems.
ear
- server.jar
- webservice.war
- jsi-dashboard.war
- META-INF
- jboss-deployment-structure.xml
- application.xml
- lib
- xyz.jar
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.0"> <ear-subdeployments-isolated>false</ear-subdeployments-isolated> <deployment> <exclusions> <!-- Exclude slf4j 1.6.1, we added new module in jboss with 1.7.3 --> <module name="org.apache.commons.logging" /> <module name="org.slf4j" /> <module name="org.slf4j.ext" /> <module name="org.slf4j.jcl-over-slf4j" /> <!-- Exclude slf4j-jboss-logmanager, we want to use logback that we added as a module --> <module name="org.slf4j.impl" /> <module name="org.apache.log4j" /> </exclusions> <dependencies> <!-- add our own modules --> <module name="ch.qos.logback" /> <module name="org.slf4j" slot="1.7.3"/> <module name="com.farheap.jsi"/> </dependencies> </deployment> <sub-deployment name="jsi-dashboard.war"> <exclusions> <module name="org.apache.commons.logging" /> <module name="org.slf4j" /> <module name="org.slf4j.ext" /> <module name="org.slf4j.jcl-over-slf4j" /> <module name="org.slf4j.impl" /> <module name="org.apache.log4j" /> </exclusions> <dependencies> <module name="ch.qos.logback" /> <module name="org.slf4j" slot="1.7.3"/> <module name="com.farheap.jsi"/> </dependencies> </sub-deployment> <sub-deployment name="webservice.war"> <exclusions> <module name="org.apache.commons.logging" /> <module name="org.slf4j" /> <module name="org.slf4j.ext" /> <module name="org.slf4j.jcl-over-slf4j" /> <module name="org.slf4j.impl" /> <module name="org.apache.log4j" /> </exclusions> <dependencies> <module name="ch.qos.logback" /> <module name="org.slf4j" slot="1.7.3"/> <module name="com.farheap.jsi"/> </dependencies> </sub-deployment> </jboss-deployment-structure>
The logback.xml is located and scanned every 30 seconds.
The log file specified in the logback file is created.
When setting log level to DEBUG in logback.xml on a package in the xyz.jar file, the debug is printet in the application log file, the jboss server log file and the console... happy happy
<logger name="com.farheap.jsi.property.Configuration" level="DEBUG" />
When setting log level to DEBUG in logback.xml on a package in the server.jar file, the debug is not printet anywhere... even though I can see on the logback INFO in the console, that the debug level was changed on that package. The same thing if I start the server with DEBUG on a package in server. jar ( same thing with the war files )
<logger name="com.farheap.jsi.ws" level="DEBUG" />
When setting log level to DEBUG in standalone.xml on a package in the server.jar file, the debug is printet in the jboss server log file. ( after server restart )
<logger category="com.farheap.jsi.ws"> <level name="DEBUG"/> </logger>
I guess this has something to with the class loading of JBoss.
I of cause want all my debug stuff from the application, to go in the application log file, specified in the logback.xml file. But Only the code from the xyz.jar file is working....