The file handler stops any logging output after changing "encoding" attribute in JBoss EAP 7
Environment
- Red Hat JBoss Enterprise Application Platform (EAP)
- 7.x
Issue
When setting encoding attribute on the file handler (file-handler, periodic-rotating-file-handler, size-rotating-file-handler, and periodic-size-rotating-file-handler) in CLI on JBoss EAP 7, LogManager throws the following error message in the console log and stops any logging output to the file handler:
LogManager error of type FLUSH_FAILURE: Error on flush
java.io.IOException: Stream Closed
at java.io.FileOutputStream.writeBytes(Native Method)
at java.io.FileOutputStream.write(FileOutputStream.java:326)
at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:82)
at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:140)
at org.jboss.logmanager.handlers.UninterruptibleOutputStream.flush(UninterruptibleOutputStream.java:110)
at sun.nio.cs.StreamEncoder.implFlush(StreamEncoder.java:297)
at sun.nio.cs.StreamEncoder.flush(StreamEncoder.java:141)
at java.io.OutputStreamWriter.flush(OutputStreamWriter.java:229)
at java.io.BufferedWriter.flush(BufferedWriter.java:254)
at org.jboss.logmanager.handlers.WriterHandler.safeFlush(WriterHandler.java:170)
at org.jboss.logmanager.handlers.WriterHandler.flush(WriterHandler.java:139)
at org.jboss.logmanager.ExtHandler.doPublish(ExtHandler.java:105)
at org.jboss.logmanager.handlers.WriterHandler.doPublish(WriterHandler.java:67)
at org.jboss.logmanager.ExtHandler.publish(ExtHandler.java:77)
at org.jboss.logmanager.LoggerNode.publish(LoggerNode.java:333)
at org.jboss.logmanager.LoggerNode.publish(LoggerNode.java:341)
at org.jboss.logmanager.LoggerNode.publish(LoggerNode.java:341)
at org.jboss.logmanager.LoggerNode.publish(LoggerNode.java:341)
at org.jboss.logmanager.LoggerNode.publish(LoggerNode.java:341)
at org.jboss.logmanager.LoggerNode.publish(LoggerNode.java:341)
at org.jboss.logmanager.Logger.logRaw(Logger.java:850)
at org.jboss.logmanager.Logger.log(Logger.java:802)
at org.jboss.logging.JBossLogManagerLogger.doLogf(JBossLogManagerLogger.java:53)
at org.jboss.logging.Logger.logf(Logger.java:2398)
at org.jboss.as.mail.extension.MailLogger_$logger.unboundMailSession(MailLogger_$logger.java:42)
at org.jboss.as.mail.extension.MailSessionAdd$1.handleEvent(MailSessionAdd.java:150)
at org.jboss.msc.service.ServiceControllerImpl$LifecycleListenerTask.execute(ServiceControllerImpl.java:1857)
at org.jboss.msc.service.ServiceControllerImpl$ControllerTask.run(ServiceControllerImpl.java:1556)
at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1985)
at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1487)
at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1364)
at java.lang.Thread.run(Thread.java:748)
Resolution
This is a bug in jboss-logmanager. This will be fixed in EAP 7.1.6 and EAP 7.2.1 or later.
To recover from this issue, you need to restart (not "reload") the JBoss instance.
Root Cause
- EAP 7.1.z: Content from issues.jboss.org is not included.JBEAP-15524
- EAP 7.2.x: Content from issues.jboss.org is not included.JBEAP-15527
- Upstream: Content from issues.jboss.org is not included.WFCORE-4132 / Content from issues.jboss.org is not included.LOGMGR-203
Diagnostic Steps
Steps to reproduce the issue:
-
Start an instance with the default setting
./bin/standalone.sh -
Execute the following CLI:
/subsystem=logging/periodic-rotating-file-handler=FILE:write-attribute(name=encoding,value=UTF-8) :reload -
No log message is output to
server.loguntil restarting the instance
or
-
Edit
standalone.xmlmanually and addencodingattribute in thefile-handlerlike:<periodic-rotating-file-handler name="FILE" autoflush="true"> <encoding value="UTF-8"/> <!-- add this --> <formatter> <named-formatter name="PATTERN"/> </formatter> <file relative-to="jboss.server.log.dir" path="server.log"/> <suffix value=".yyyy-MM-dd"/> <append value="true"/> </periodic-rotating-file-handler> -
Start the JBoss instance after the above manual file change
-
No log message is output to
server.logafter the logging subsystem is initialized.
In the latter scenario, you can avoid the issue by adding "handler.FILE.encoding=UTF-8" in logging.properties when you add "<encoding value="UTF-8"/>" in standalone.xml. Otherwise, you need to restart the instance again to resolve the issue.
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.