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
Related
I want to remove the unnecessary log's that are generated automatically by log4j when i run my suite, I only want the log's which i wrote in the code, please help.
As you can see my actual log's starts from Launched flipcart.com and end with Closed the current window
Also check the log4j2.xml file.
See second answer in How to exclude a single Class from a Log4j Logger / Appender?
Replace
<logger name="com.example.FifthClass">
<level value="FATAL"/>
</logger>
with e.g.
<logger name="io.netty">
<level value="FATAL"/>
</logger>
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])
Is there anything in the prod-ready logging world like env-dependent logging profiles. What I mean. Usually one wants different level of detail for different environments.
In action it requires creating multiple log configuration files and when having many environments adding new logger becomes real pain. What I am looking for is:
<logger name="com.google.xyz" additivity="true">
<level value="DEBUG" env="DEV" />
<level value="INFO" env="UAT" />
<level value="ERROR" env="PROD" />
<appender-ref ref="xyz-appender"/>
</logger>
Is such thing exists for some prod-ready Java logging solution?
Logback (an excellent choice for logging with SLF4J) seems to offer this capability in a verbose, but very configurable form.
Conditional processing of configuration files
while executing a small application in Eclipse, I get an Http Status 500 error from the Tomcat server that I am running through Eclipse itself...
HTTP Status 500 -
--------------------------------------------------------------------------------
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
java.lang.NullPointerException
org.apache.struts2.impl.StrutsActionProxy.getErrorMessage (StrutsActionProxy.java:69)
com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:185)
org.apache.struts2.impl.StrutsActionProxy.prepare(StrutsActionProxy.java:63)
org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:39)
com.opensymphony.xwork2.DefaultActionProxyFactory.createActionProxy(DefaultActionProxyFactory.java:58)
org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:500)
org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:434)
note The full stack trace of the root cause is available in the Apache Tomcat/7.0.8 logs.
This message from the server says that error was caused by a "NullPointerException". The last line says that "full stack trace is available in Apache Tomcat/7.0.8 logs.
I have checked the logs created in my workspace ( ${catalina.base} is set to a folder in my workspace) but the logs don't provide any details about the "NullPointerException". The only thing present in the logs is...
0:0:0:0:0:0:0:1 - - [03/May/2012:15:19:16 +0530] "GET /KurniawanChap02Struts/ HTTP/1.1" 500 1789
I have also tried increasing the "logging levels" but even that doesn't help.
What should I do to access the detailed logs of the server ?
I had some similar errors when I was using different versions of Apache Commons. For getting more details about these errors I changed the default loggind of Tomcat to log4j. You can see the detailed instructions in Apache Tomcat 7 (7.0.27) - Logging in Tomcat
This is xml example for log4j that I was using:
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
<appender name="STDOUT" class="org.apache.log4j.ConsoleAppender">
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d %-5p (%c.java:%L).%M - %m%n" />
</layout>
</appender>
<!-- CATALINA -->
<logger name="org.apache.catalina.session">
<level value="INFO" />
</logger>
<!-- TOMCAT -->
</logger>
<logger name="org.apache.jasper.compiler">
<level value="INFO" />
</logger>
<!-- COMMONS -->
<logger name="org.apache.commons.digester">
<level value="INFO" />
</logger>
<root>
<priority value="TRACE" />
<appender-ref ref="STDOUT" />
</root>
</log4j:configuration>
I hope that this can hep you.
I had the same problem. I removed the unused project that was referenced in properties->Java Build Path->Projects. It was showing that xyz(project Name) is missing.
I removed xyz.
Sometimes you can check in properties->Java Build Path->libraries whether any jar is missing. If so, you can add that jar from the classpath.