Suddenly (after working fine for some time), WildFly 9.0.1 (and also 9.0.2) seem to have somehow lost the CONSOLE handler for logging.
When trying to debug an application from NetBeans 8.0.2, the Console window shows:
ERROR [stderr] (default task-14) Handler java.util.logging.ConsoleHandler is not defined
as last entry, and the web application seems to be stuck (before actually starting).
In WildFly's management console, there seems to be a root logger using 2 handlers: CONSOLE and FILE.
Both Handlers seem to be existing in standalone-full.xml:
...
<subsystem xmlns="urn:jboss:domain:logging:3.0">
<console-handler name="CONSOLE">
<level name="INFO"/>
<formatter>
<named-formatter name="COLOR-PATTERN"/>
</formatter>
</console-handler>
<periodic-rotating-file-handler name="FILE" autoflush="true">
<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>
...
<root-logger>
<level name="INFO"/>
<handlers>
<handler name="CONSOLE"/>
<handler name="FILE"/>
</handlers>
</root-logger>
...
</subsystem>
...
When changing config in the management console, I can delete the handlers out of the root logger. Then I can save, but taking them in again seems impossible, since I get the WFLYCTL0158, telling that the handler would not be defined.
JBoss Knowledge base says you should ensure right jars (logback-classic-1.1.9.jar and logback-core-1.1.9.jar in that case) are in WEB-INF/lib directory if you are using an application framework.
UPDATE
For those who do not have access to link above, and wonder what the next steps are, you can add following to pom.xml to make it work with your application framework, which will then add it to WEB-INF/lib during the build.
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.2.3</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
<version>1.2.3</version>
</dependency>
Related
I added this config to my subsystem im JBoss and i got an error by build.
The config part:
<subsystem xmlns="urn:jboss:domain:logging:3.0">
<console-handler name="CONSOLE">
<level name="INFO"/>
<formatter>
<named-formatter name="COLOR-PATTERN"/>
</formatter>
</console-handler>
<periodic-rotating-file-handler name="FILE" autoflush="true">
<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>
<!-- MY CONFIGURATION PART -->
<file-handler name="ABC-FILE" autoflush="true">
<level name="INFO"/>
<formatter>
<pattern-formatter pattern="%-5p %d %C (%F:%M:%L) - %m%n"/>
</formatter>
<file relative-to="jboss.server.log.dir" path="ABC-Activity.log"/>
<suffix value=".yyyy-MM-dd"/>
<append value="true"/>
</file-handler>
<logger category="com.my.project.ActivityLogger">
<level name="INFO"/>
<handlers>
<handler name="ABC-FILE"/>
</handlers>
</logger>
here the error by build the web-app:
ERROR [org.jboss.as.server] (Controller Boot Thread) WFLYSRV0055: Caught exception during boot: org.jboss.as.controller.persistence.ConfigurationPersistenceException: WFLYCTL0085: Failed to parse configuration
at org.jboss.as.controller.persistence.XmlConfigurationPersister.load(XmlConfigurationPersister.java:131)
at org.jboss.as.server.ServerService.boot(ServerService.java:357)
at org.jboss.as.controller.AbstractControllerService$1.run(AbstractControllerService.java:299)
at java.lang.Thread.run(Thread.java:745)
Caused by: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[113,17]
Message: WFLYCTL0198: Unexpected element '{urn:jboss:domain:logging:3.0}suffix' encountered
at org.jboss.as.controller.parsing.ParseUtils.unexpectedElement(ParseUtils.java:89)
at org.jboss.as.logging.LoggingSubsystemParser_3_0.parseFileHandlerElement(LoggingSubsystemParser_3_0.java:521)
at org.jboss.as.logging.LoggingSubsystemParser_3_0.readElement(LoggingSubsystemParser_3_0.java:152)
at org.jboss.as.logging.LoggingSubsystemParser_3_0.readElement(LoggingSubsystemParser_3_0.java:97)
at org.jboss.staxmapper.XMLMapperImpl.processNested(XMLMapperImpl.java:110)
at org.jboss.staxmapper.XMLExtendedStreamReaderImpl.handleAny(XMLExtendedStreamReaderImpl.java:69)
at org.jboss.as.server.parsing.StandaloneXml_4.parseServerProfile(StandaloneXml_4.java:546)
at org.jboss.as.server.parsing.StandaloneXml_4.readServerElement(StandaloneXml_4.java:242)
at org.jboss.as.server.parsing.StandaloneXml_4.readElement(StandaloneXml_4.java:141)
at org.jboss.as.server.parsing.StandaloneXml.readElement(StandaloneXml.java:103)
at org.jboss.as.server.parsing.StandaloneXml.readElement(StandaloneXml.java:49)
at org.jboss.staxmapper.XMLMapperImpl.processNested(XMLMapperImpl.java:110)
at org.jboss.staxmapper.XMLMapperImpl.parseDocument(XMLMapperImpl.java:69)
at org.jboss.as.controller.persistence.XmlConfigurationPersister.load(XmlConfigurationPersister.java:123)
... 3 more
11:52:57,717 FATAL [org.jboss.as.server] (Controller Boot Thread) WFLYSRV0056: Server boot has failed in an unrecoverable manner; exiting. See previous messages for details.
i used this docu https://docs.jboss.org/author/display/AS71/Logging+Configuration#LoggingConfiguration-rootlogger
what i wrong???
In our experience, this was caused due to a wrong standalone.xml configuration.
Jboss is very complicated. They keep specific history files for standalone.xml configurations. I don't know the reasons, thats a question for their developers.
For some reason sometimes standalone.xml has 0 bytes.
Look for the file in
JBOSS_AS_HOME/standalone/configuration/
In our case it was like this
drwxr-xr-x. 11 user user 4096 Mar 14 12:44 standalone_xml_history
-rw-rw-r--. 1 user user 0 Mar 14 12:44 standalone.xml
We replaced with latest "automatic backup/history" from standalone_xml_history directory; and everything went back to normal.
We am using JBoss 7 in our project and have written the logging configuration in standalone.xml file like this,
<subsystem xmlns="urn:jboss:domain:logging:1.0">
.
.
.
<logger category="com.xyz.abc.aspect">
<level name="DEBUG"/>
<handlers>
<handler name="FILE"/>
</handlers>
</logger>
.
.
</subsystem>
Now a situation has arose that i wanted to change the logging configuration by adding use-parent-handlers="false" to avoid the log being redirected to parent handler , now when i add this to standalone.xml
<logger category="com.xyz.abc.aspect" use-parent-handlers="false">
<level name="DEBUG"/>
<handlers>
<handler name="FILE"/>
</handlers>
</logger>
and restart the server the logging configuration is reverted back by JBoss to the previous state i.e
<logger category="com.xyz.abc.aspect">
<level name="DEBUG"/>
<handlers>
<handler name="FILE"/>
</handlers>
</logger>
I have tried deleting standalone_xml_history directory and files under it , but nothing is preventing the overwriting behaviour, can any one please suggest.
I'm not 100% sure, but restarting the server probably causes a write-back action of the config. That means your config gets overwritten by with the "current" config the server knows which is the version before you edited the file.
You could simply use the management console
confguration > core > logging or use the CLI /subsystem=logging/logger=change.me.please:write-attribute(name="use-parent-handlers", value="false") to make those changes.
Alternatively change the config file when the server is stopped.
You need to update standalone.initial.xml in standalone_xml_history directory. Then restart Jboss, your changes would take place.
reference- https://docs.jboss.org/author/display/AS7/Configuration%20file%20history.html
We have Wildfly running on Domain mode in our production system. There are around 10 web servers and there is only on log file for all 10 servers. The log file is located under /var/log/wildfly/wildfly.log file. The last time I checked, the files was around 5 GB. My problems are:
Is there any way to separate the server logs so that each server has its own log file?
Is there any way to set the log file to max size limit to prevent over-growing?
Is there any way to delete the log file and start over? Logs before 2 days is useless for me so most of the data in the log file is redundant.
Regard
For (1) I'm not sure - is this OS installed? I don't have that file but I just extract the tarball.
For (2) and (3) I think it's a case of looking in domain/configuration/domain.xml or standalone/configuration/standalone.xml for the appropriate ("default"?) periodic-rotating-file-handler and adding, say:
<rotate-size value="20k"/> <!-- Limit on size of file -->
<max-backup-index value="1"/> <!-- Number of log files to keep -->
create size-rotating-file-handler
<size-rotating-file-handler name="FILE_SIZE">
<level name="DEBUG"/>
<file relative-to="jboss.server.log.dir" path="server.log"/>
<rotate-size value="1m"/> <!-- the size, could be 100k, 10m etc-->
<max-backup-index value="5"/> <!-- backup index, default is 1, please set it to a large number -->
<append value="true"/>
</size-rotating-file-handler>
use the handler created
<root-logger>
<level name="INFO"/>
<handlers>
<handler name="CONSOLE"/>
<handler name="FILE"/>
<handler name="FILE_SIZE"/> <!-- this is what you need to add -->
</handlers>
</root-logger>
I have implemented java.util.logging.Handler (LogHandler) and my Wildfly configuration is pretty much vanilla. Everything is fine and works as expected. The idea is now, to split the logging part into two files. What I have done is the following:
<periodic-rotating-file-handler name="PROTOCOL" autoflush="true">
<level name="INFO"/>
<formatter>
<named-formatter name="PATTERN"/>
</formatter>
<file relative-to="jboss.server.log.dir" path="protocol.log"/>
<suffix value=".yyyy-MM-dd"/>
<append value="true"/>
</periodic-rotating-file-handler>
...
<logger category="com.test.transport" use-parent-handlers="false">
<level name="INFO"/>
<handlers>
<handler name="PROTOCOL"/>
<handler name="CONSOLE"/>
</handlers>
</logger>
Works as expected as well, I got another file with the log from com.test.transport.
My problem is, since I have changed my wildfly configuration, everything in the PROTOCOL log file does not get published by my LogHandler.
Edit:
#Singleton
#Startup
public class LogHandler extends ExtHandler {
#Override
public void publish(LogRecord record) {
String message = record.getMessage();
}
}
If you're just looking to split your application log messages into a separate file what you have, minus your LogHandler should do that.
If you want to use your own log handler you need to install it as a module. See the CLI module add --help for details. There is no way to have custom handlers in your deployment. They need to be defined as modules.
You then need to add the handler as a custom-handler to the logging subsystem.
Here's some example commands to add the module and create the custom handler.
module add --name=com.test.transport --resources=/path/to/jar/transport-logging.jar
/subsystem=logging/custom-handler=PROTOCOL:add(class=com.test.transport.LogHandler, module=com.test.transport, level=INFO, named-formatter=PATTERN, properties={file="${jboss.server.log.dir}/protocol.log"})
/subsystem=logging/logger=com.test.transport:add(level=INFO, use-parent-handlers=false, handlers=[CONSOLE, PROTOCOL])
Why does log4j print:
17:58:30,623 INFO [stdout] (http--127.0.0.1-8080-5)
The complete message is:
17:58:30,623 INFO [stdout] (http--127.0.0.1-8080-5) 2012-12-09 17:58:30.623 [INFO] com.edfx.adb.web.controller.AuthController#login - A message
I am using JBoss AS7 and I have exclude log4j like:
<jboss-deployment-structure>
<deployment>
<exclusions>
<module name="org.apache.log4j" />
</exclusions>
</deployment>
</jboss-deployment-structure>
And my log4j.properties is:
log4j.rootLogger=INFO, CA
log4j.appender.CA=org.apache.log4j.ConsoleAppender
log4j.appender.CA.layout=org.apache.log4j.PatternLayout
log4j.appender.CA.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss.SSS} [%p] %c#%M - %m%n
I want to print the message as:
2012-12-09 17:58:30.623 [INFO] com.edfx.adb.web.controller.AuthController#login - A message
How can I do it?
It's because JBoss STDIO wraps stdout and stderr and the log4j ConsoleAppender outputs to stdout.
You can accomplish the same thing your trying to do by configuring the logging subsystem instead of using a log4j.properties file. Using the logging subsystem there is also no reason to exclude the dependency in the jboss-deployment-structure.xml.
<subsystem xmlns="urn:jboss:domain:logging:1.1">
<console-handler name="CONSOLE">
<level name="INFO"/>
<formatter>
<pattern-formatter pattern="%d{yyyy-MM-dd HH:mm:ss.SSS} [%p] %c#%M - %m%n"/>
</formatter>
</console-handler>
<!-- other handlers and loggers -->
<root-logger>
<level name="INFO"/>
<handlers>
<handler name="CONSOLE"/>
</handlers>
</root-logger>
</subsystem>