[jboss-jira] [JBoss JIRA] (WFCORE-478) log4j ConsoleAppender won't display messages with per-deployment logging
James Perkins (JIRA)
issues at jboss.org
Tue Mar 3 12:01:50 EST 2015
[ https://issues.jboss.org/browse/WFCORE-478?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13045761#comment-13045761 ]
James Perkins commented on WFCORE-478:
--------------------------------------
Because of the way the {{ConsoleAppender}} works and the fact the WildFly wraps {{System.out}} and {{System.err}} there are potential deadlocks with using a {{ConsoleAppender}} with per-deployment logging.
If you're not using any other special appenders you could just use a {{logging.properties}} file and the {{org.jboss.logmanager.handlers.ConsoleHandler}}. This will work the same regardless of the logging facade you use. The JBoss Log Manager {{logging.properties}} file looks similar to a log4j one. Here's an example of one using the {{ConsoleHandler}}
{code}
# Additional logger names to configure (root logger is always configured)
loggers=org.jboss.as.logging
# Root logger level
logger.level=INFO
# Root logger handlers
logger.handlers=CONSOLE
logger.org.jboss.as.logging.level=TRACE
# Console handler configuration
handler.CONSOLE=org.jboss.logmanager.handlers.ConsoleHandler
handler.CONSOLE.properties=autoFlush
handler.CONSOLE.level=TRACE
handler.CONSOLE.autoFlush=true
handler.CONSOLE.formatter=PATTERN
# Formatter pattern configuration
formatter.PATTERN=org.jboss.logmanager.formatters.PatternFormatter
formatter.PATTERN.properties=pattern
formatter.PATTERN.pattern=%d{HH:mm:ss,SSS} %-5p [%c] %s%e%n
{code}
Another option would be use a [jboss-deployment-structure.xml to exclude the logging subsystem|https://docs.jboss.org/author/display/WFLY8/How+To#HowTo-HowdoIusemyownversionoflog4j%3F]. You'd then need to provide your own version of log4j in your deployment. That should get around the possible deadlock if you'd rather use log4j appenders.
A third option would be to use [logging profiles|https://docs.jboss.org/author/display/WFLY8/Logging+Configuration#LoggingConfiguration-LoggingProfiles]. With these you can isolate the logging configuration per-deployment. I would advise not writing to the same file, e.g. {{server.log}}, though in each profile. Using a console handler should be fairly safe assuming {{System.out}} and/or {{System.err}} use appropriate locking.
As to changing the standalone.xml I hope you're not manually changing it :) It's much better to use CLI or some sort of management interface to make changes like that. They happen at runtime so there's no need to restart the server.
> log4j ConsoleAppender won't display messages with per-deployment logging
> ------------------------------------------------------------------------
>
> Key: WFCORE-478
> URL: https://issues.jboss.org/browse/WFCORE-478
> Project: WildFly Core
> Issue Type: Bug
> Components: Logging
> Reporter: James Perkins
> Assignee: James Perkins
> Priority: Minor
>
> Add the following log4j.properties file to a deployment and try to log.
> {code}
> # Root logger option
> log4j.rootLogger=INFO, stdout
> # Direct log messages to stdout
> log4j.appender.stdout=org.apache.log4j.ConsoleAppender
> log4j.appender.stdout.Target=System.out
> log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
> log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.11#6341)
More information about the jboss-jira
mailing list