-
1. Re: Logging with slf4j in @Schedule EJB Method
jamezp Feb 20, 2017 12:42 PM (in response to ju113n_soc)What does your logging.properties look like? Where is the file located in your EAR?
If you're using WildFly 10+ you can view what logging configuration your deployment is using with CLI.
/deployment=NAME.ear/subsystem=logging:read-children-names(child-type=configuration)
If you just see "default" that means the logging.properties is not being found in your deployment. You can execute the command on the sub-deployments or use the read-resource(recursive=true, include-runtime=true) if you want to see the resolved configuration.
--
James R. Perkins
-
2. Re: Logging with slf4j in @Schedule EJB Method
ju113n_soc Apr 14, 2017 4:27 AM (in response to jamezp)Here is my logging.properties :
loggers=com.cie.xyz logger.level=INFO logger.handlers=FILE,CONSOLE logger.com.cie.xyz.level=INFO logger.com.cie.xyz.useParentHandlers=true handler.CONSOLE=org.jboss.logmanager.handlers.ConsoleHandler handler.CONSOLE.level=INFO handler.CONSOLE.formatter=COLOR-PATTERN handler.CONSOLE.properties=autoFlush,target,enabled handler.CONSOLE.autoFlush=true handler.CONSOLE.target=SYSTEM_OUT handler.CONSOLE.enabled=true handler.FILE=org.jboss.logmanager.handlers.PeriodicRotatingFileHandler handler.FILE.level=INFO handler.FILE.formatter=PATTERN handler.FILE.properties=append,autoFlush,enabled,suffix,fileName handler.FILE.constructorProperties=fileName,append handler.FILE.append=true handler.FILE.autoFlush=true handler.FILE.enabled=true handler.FILE.suffix=.yyyy-MM-dd handler.FILE.fileName=C\:\\Program Files\\JBoss\\wildfly-10.1.0.Final\\standalone\\log\\cgr.log formatter.PATTERN=org.jboss.logmanager.formatters.PatternFormatter formatter.PATTERN.properties=pattern formatter.PATTERN.pattern=%d{yyyy-MM-dd HH:mm:ss,SSS} %-5p [%c] %m%n formatter.COLOR-PATTERN=org.jboss.logmanager.formatters.PatternFormatter formatter.COLOR-PATTERN.properties=pattern formatter.COLOR-PATTERN.pattern=%K{level}%d{yyyy-MM-dd HH:mm:ss,SSS} %-5p [%c] %m%n
This file is located in ear module in the directory src/main/application/META-INF.
After compilation I have :
xxx-ear
|-- META-INF
|-- application.xml
|-- logging.properties
|-- APP-INF
|-- xxx-ejb
|-- xxx-war
I use wildfly 10.1.0 and when I execute this command :
/deployment=xxx-ear-1.6.0.ear/subsystem=logging:read-children-names(child-type=configuration)
I get :
{ "outcome" => "success", "result" => ["default"] }
... so my logging.properties is not found and I wonder why.
If I put the logging.properties in the META-INF of the ejb module, it is recognized, the above command (with sub-deployment) return the path of the logging.properties. But my goal is to define logging in the whole application.
-
3. Re: Logging with slf4j in @Schedule EJB Method
jamezp Apr 17, 2017 3:06 PM (in response to ju113n_soc)Having the logging.properties in the EAR/META-INF should definitely work. I tested an EAR on WildFly 10.1.0.Final and got the following results:
[standalone@localhost:9990 /] /deployment=ear.ear/subsystem=logging:read-children-names(child-type=configuration) { "outcome" => "success", "result" => ["ear.ear/META-INF/logging.properties"] } [standalone@localhost:9990 /] /deployment=ear.ear/subdeployment=batch-chunk.war/subsystem=logging:read-children-names(child-type=configuration) { "outcome" => "success", "result" => ["ear.ear/META-INF/logging.properties"] }
I can see messages being logged into the file I specified in the logging.properties as well.
logger.level=INFO logger.handlers=FILE,CONSOLE handler.CONSOLE=org.jboss.logmanager.ha handler.CONSOLE.formatter=COLOR-PATTERN handler.CONSOLE.properties=autoFlush,target,enabled handler.CONSOLE.autoFlush=true handler.CONSOLE.target=SYSTEM_OUT handler.CONSOLE.enabled=true handler.FILE=org.jboss.logmanager.handlers.PeriodicRotatingFileHandler handler.FILE.level=INFO handler.FILE.formatter=PATTERN handler.FILE.properties=append,autoFlush,enabled,suffix,fileName handler.FILE.constructorProperties=fileName,append handler.FILE.append=true handler.FILE.autoFlush=true handler.FILE.enabled=true handler.FILE.suffix=.yyyy-MM-dd handler.FILE.fileName=${jboss.server.log.dir}/ear.log formatter.PATTERN=org.jboss.logmanager.formatters.PatternFormatter formatter.PATTERN.properties=pattern formatter.PATTERN.pattern=%d{yyyy-MM-dd HH:mm:ss,SSS} %-5p [%c] %m%n formatter.COLOR-PATTERN=org.jboss.logmanager.formatters.PatternFormatter formatter.COLOR-PATTERN.properties=pattern formatter.COLOR-PATTERN.pattern=%K{level}%d{yyyy-MM-dd HH:mm:ss,SSS} %-5p [%c] %m%n
Maybe check the logging subsystem configuration. You'd want to check the add-logging-api-dependcies and use-deployment-logging-config attributes. Both should be set to true which is the default.
You could turn on trace logging for org.jboss.as.logging as well. If the configuration file is being found you should see some log messages like the following:
11:58:58,791 TRACE [org.jboss.as.logging] (MSC service thread 1-6) Scanning for logging configuration files. 11:58:58,791 DEBUG [org.jboss.as.logging] (MSC service thread 1-6) Found logging configuration file: "/content/ear.ear/META-INF/logging.properties" 11:58:58,792 TRACE [org.jboss.as.logging] (MSC service thread 1-6) Registering LogContext org.jboss.logmanager.LogContext@4fd916da for deployment ear.ear 11:58:58,793 TRACE [org.jboss.as.logging] (MSC service thread 1-6) Scanning for logging configuration files. 11:58:58,793 TRACE [org.jboss.as.logging] (MSC service thread 1-6) Registering LogContext org.jboss.logmanager.LogContext@4fd916da for deployment batch-chunk.war 11:58:58,793 TRACE [org.jboss.as.logging] (MSC service thread 1-6) Scanning for logging configuration files. 11:58:58,793 TRACE [org.jboss.as.logging] (MSC service thread 1-6) Registering LogContext org.jboss.logmanager.LogContext@4fd916da for deployment batch-jdbc-chunk.war 11:58:58,793 TRACE [org.jboss.as.logging] (MSC service thread 1-6) Scanning for logging configuration files. 11:58:58,794 TRACE [org.jboss.as.logging] (MSC service thread 1-6) Registering LogContext org.jboss.logmanager.LogContext@4fd916da for deployment batch-ejb.jar
--
James R. Perkins