0

I am trying to make per-deployment logging work. I have war archive with logging.properties in WEB-INF/ with contents:

ru.home.level=FINEST

And in servlet I do:

protected Logger log = Logger.getLogger("ru.home.Something");

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        log.log(Level.FINEST, "Hello");
        resp.getWriter().write("<b>tralalala</b>");
        log.log(Level.FINEST, "Bye");
    }

According to WildFly logging configuration documentation during the deployment it should scan and find my properties file in the appropriate place. But seems like it doesnt scan at all. What am I doing wrong? (https://docs.jboss.org/author/display/WFLY9/Logging+Configuration#LoggingConfiguration-PerdeploymentLogging) Also:

/subsystem=logging:read-attribute(name=use-deployment-logging-config)

returns:

{
    "outcome" => "success",
    "result" => true
}
Sevan
  • 669
  • 1
  • 5
  • 18
user3070377
  • 441
  • 4
  • 10
  • Does it work if you change your properties from `ru.home.level=FINEST` to `ru.home.Something.level=FINEST`? – jmehrens Nov 29 '15 at 21:37

1 Answers1

0

Looks like there's an error in the documentation. The logging.properties file should in the WEB-INF/classes directory.

Also the logging.properties file needs to be in a slightly different format than a JUL logging.properties file.

Example:

loggers=ru.home

logger.level=INFO
logger.handlers=FILE

logger.ru.home.level=FINEST

handler.FILE=org.jboss.logmanager.handlers.SizeRotatingFileHandler
handler.FILE.level=ALL
handler.FILE.formatter=PATTERN
handler.FILE.properties=append,autoFlush,enabled,maxBackupIndex,rotateOnBoot,rotateSize,fileName
handler.FILE.append=true
handler.FILE.autoFlush=true
handler.FILE.enabled=true
handler.FILE.maxBackupIndex=10
handler.FILE.rotateOnBoot=false
handler.FILE.rotateSize=52428800
handler.FILE.fileName=${jboss.server.log.dir}/myapp.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] (%t) %s%e%n

One thing to note too is per-deployment logging doesn't inherit any configuration from the subsystem. You'd need to fully configure logging in your deployment.

James R. Perkins
  • 16,800
  • 44
  • 60