Can Per-deployment Logging work together with Logging sub system for Jboss EAP 6.4?

1k views Asked by At

I have multiple wars running on a standalone jboss server. I have logging subsystem configured in the standalone.xml. I referred this redhat link on Add Per-deployment Logging to an Application to create a log handler specific for one of the apps.

I created logging.properties file in the app war under META-INF folder with following content

loggers=com.company

logger.com.company.level=TRACE
logger.com.company.useParentHandlers=true
logger.com.company.handlers=TESTFILE

# A handler configuration
handler.TESTFILE=org.jboss.logmanager.handlers.FileHandler
handler.TESTFILE.level=TRACE
handler.TESTFILE.formatter=PATTERN1
handler.TESTFILE.properties=append,autoFlush,enabled,suffix,fileName
handler.TESTFILE.constructorProperties=fileName,append
handler.TESTFILE.append=true
handler.TESTFILE.autoFlush=true
handler.TESTFILE.enabled=true
handler.TESTFILE.fileName=${jboss.server.log.dir}/app.log

# The formatter to use
formatter.PATTERN1=org.jboss.logmanager.formatters.PatternFormatter
formatter.PATTERN1.properties=pattern
formatter.PATTERN1.constructorProperties=pattern
formatter.PATTERN1.pattern=%d %-5p %c: %m%n

I deployed the app but it didn't do anything apart from what is configured in standalone.xml logging sub system. Is this setup supposed to work on EAP 6.4 ?

2

There are 2 answers

15
James R. Perkins On BEST ANSWER

Yes this should work in JBoss EAP 6.4. You may want to try moving the logging.properties file to the WAR/WEB-INF/classes. There may have been a bug where it fails to look in the WAR/WEB-INF directory.

If that doesn't work you could also turn on trace logging for org.jboss.as.logging which should show the logging.properties file being found in your deployment.

The following CLI command will enable trace logging to see the details of what the logging subsystem is doing.

/subsystem=logging/logger=org.jboss.as.logging:add(level=TRACE)

If you want to see these log messages on the console you'll need to enable trace logging for the console tool.

/subsystem=logging/console-handler=CONSOLE:write-attribute(name=level, value=TRACE)
0
Arun K On

Thanks a lot to @James R Perkins for his answer and comments

here is the final configuration that worked

loggers=com.company.a,com.company.b.interceptor.app

logger.level=INFO
logger.handlers=APPLOG

logger.com.company.a.level=INFO
logger.com.company.a.useParentHandlers=false
logger.com.company.a.handlers=APPLOG

logger.com.company.b.interceptor.app.level=INFO
logger.com.company.b.interceptor.app.useParentHandlers=false
logger.com.company.b.interceptor.app.handlers=INTERCEPTLOG

# A handler configuration
handler.APPLOG=org.jboss.logmanager.handlers.PeriodicRotatingFileHandler
handler.APPLOG.level=INFO
handler.APPLOG.formatter=PATTERN
handler.APPLOG.properties=append,autoFlush,enabled,suffix,fileName
handler.APPLOG.constructorProperties=fileName,append
handler.APPLOG.append=true
handler.APPLOG.autoFlush=true
handler.APPLOG.enabled=true
handler.APPLOG.suffix=.yyyy-MM-dd
handler.APPLOG.fileName=${jboss.server.log.dir}/APPLOG.log

handler.INTERCEPTLOG=org.jboss.logmanager.handlers.PeriodicRotatingFileHandler
handler.INTERCEPTLOG.level=INFO
handler.INTERCEPTLOG.formatter=PATTERN
handler.INTERCEPTLOG.properties=append,autoFlush,enabled,suffix,fileName
handler.INTERCEPTLOG.constructorProperties=fileName,append
handler.INTERCEPTLOG.append=true
handler.INTERCEPTLOG.autoFlush=true
handler.INTERCEPTLOG.enabled=true
handler.INTERCEPTLOG.suffix=.yyyy-MM-dd
handler.INTERCEPTLOG.fileName=${jboss.server.log.dir}/INTERCEPTLOG.log

# The formatter to use
formatter.PATTERN=org.jboss.logmanager.formatters.PatternFormatter
formatter.PATTERN.properties=pattern
formatter.PATTERN.constructorProperties=pattern
formatter.PATTERN.pattern=%d %-5p %c: %m%n