How to specify log4j.xml with aync - java

My Tomcat log4j.xml has a dependency on graylog2 server.
Few days back, my graylog2 server down due to storage issue after that my Tomcat's stop responding in between production hour. Then I came to know my log4j.xml has sync method that store the log first to graylo console then catalina.
How to come out with this dependecy?

Related

Why is the WildFly console log hijacking my WAR's log4j log?

I have 7 different WARs deployed to the same WildFly / JBoss server. Each WAR is identical in core design and Log4j configuration. Each WAR generates its own log file via its own individual custom log4j.xml. Each log is written to an individual folders.
1 of the 7 deployed WARs keeps getting the logging hijacked by WildFly's console.log. It will begin writing to its own log for 5-10 lines during initialization, then stop; the rest of the logging will be directed to the console.log.
If I re-install the WAR after this happens, it will write to both its own individual log and the WildFly console.log. If I restart WildFly, it will behave as described previously - begin logging to its own log, then continue on console.log.
The only thing unique about this WAR vs the other 6 is that this project uses JAXB; none of the other WARs use JAXB.
Is there some sort of unknown interaction between JAXB and Log4j and WildFly that might be causing this? I suspect, but cannot yet prove, the hijack is happening after the classes using JAXB are loaded by the ClassLoader.
jboss-7.2.0.Final , jdk-7u80x64, Log4j-1.2.13.jar
You may need to try move the logging.properties file to the WAR/WEB-INF/classes. I guess old Jboss EAP 6.4, There may have been a bug where it fails to look in the WAR/WEB-INF directory.
If that doesn't work you have to turn on trace logging for org.jboss.as.logging which should show the logging.properties file is found in your deployment.
The following CLI command will enable trace logging to see the details of what the logging subsystem is doing.
/subsystem=logging/logger=org.jboss.as.logging:add(level=TRACE)
If you want to see these log messages on the console you'll need to enable trace logging for the console tool.
/subsystem=logging/console-handler=CONSOLE:write-attribute(name=level, value=TRACE)
resources:
sect-per-deployment_logging
Logging Configuration
Solved by excluding the log4j module from the application via /WEB-INF/jboss-deployment-structure.xml
<jboss-deployment-structure>
<deployment>
<exclusions>
<module name="org.apache.log4j" />
</exclusions>
</deployment>
</jboss-deployment-structure>

How do I change log level in runtime without restarting Vert.x application

I know that we can change log level by putting it in vertx-default-jul-logging.properties file.
java.util.logging.ConsoleHandler.formatter=java.util.logging.SimpleFormatter
java.util.logging.ConsoleHandler.level=FINER
java.util.logging.FileHandler.limit=10000000
java.util.logging.FileHandler.count=10
java.util.logging.FileHandler.level=FINER
java.util.logging.FileHandler.formatter=java.util.logging.SimpleFormatter
But I need to restart the application when we change log level in this file as it gets built with application. Is there any way to change the log level without restarting the application like we can do in jboss by jboss cli.
This file doesn't have to be built with the application. It just has to be on the classpath.
But anyway, I don't believe JDK logging supports hot reload of a configuration file. There are other logging tools which do though. Like Logback-classic.
Logback-classic can scan for changes in its configuration file and automatically reconfigure itself when the configuration file changes.
For example, to reload every five seconds:
<configuration scan="true" scanPeriod="5 seconds" >
...
</configuration>
Vert.x can be configured to use different logging frameworks. To do so, you must set the vertx.logger-delegate-factory-class-name system property. As Logback-classic is an slf4j implementation, you need:
-Dvertx.logger-delegate-factory-class-name=io.vertx.core.logging.SLF4JLogDelegateFactory

How to set maintenance page when server directory is getting updated in WILDFLY 10?

We are using WILDFLY 10 server for our website. We need to set a maintenance page when a new war file is getting uploaded to server directory for new changes. How to do this?
in wildfly 10 server, i have added two line in standalone.xml. which are,
1.<filter-ref name="404-handler"/>
<error-page name="404-handler" path="${jboss.home.dir}/welcome-content/test.html" code="404"/>
1st line add in Host tree of subsystem in standalone.xml file
and 2nd line add in filters tree .
it worked for me. hope it will work for you too.

Tomcat logging configuration

I am using Tomcat 7 / 8 in cloud, in panel log viewer got below log files:
Log files
Catalina.out
instance.log
access log
And i found official document from tomcat, but still confused.
https://tomcat.apache.org/tomcat-7.0-doc/logging.html
I cannot access such folder like /apache/apache-tomcat-8.0.15/logs
Can explain the usage for each log file with sample words?
In simple words:
Catalina.out - Some app logs and system specific logs
instance.log - Application specific logs
access log - Contains the app paths that were accessed (the users' Web requests)
More details / bg:
Catalina.out : "When running Tomcat on unixes, the console output is usually redirected to the file named catalina.out", so your System.out.println, logger.info, or exception should be found in it.
instance.log : the log related to application running status / life cycle.
There are two main approaches to configure Tomcat logs:
a. The java.util.logging (JUL) API
found at ${catalina.base}/conf/logging.properties
b. Apache log4j
found at $CATALINA_BASE/lib/log4j.properties. Don't confuse this with application's logs.
log4j.jar and log4j.properties go into WEB-INF/lib and WEB-INF/classes, respectively, in your web application.

Error 500: java.lang.NoSuchMethodError: org/apache/commons/fileupload/FileUploadBase.isMultipartContent(

Error 500: java.lang.NoSuchMethodError: org/apache/commons/fileupload/FileUploadBase.isMultipartContent(Lorg/apache/commons/fileupload/RequestContext;)
This is the error that I found in Websphere but I don't get any error in Apache tomcat. If anybody having solution. please reply me fast.
I am using following jar:
1.) commons-fileupload-1.3.jar
2.) commons-io-2.4.jar
See 500 means simple there is some problem in servlet code.
you might done something wrong in your servlet code.
try with putting upgraded jar files.
and also put your code so that you have written.
A comment on this post helped me, so I'm writing it as an answer.
It may help to set the classloader policy on the server to "Multiple". To do this in Websphere, navigate as follows:
Log in to the Websphere console (typically http://localhost:9060/ibm/console/login.do)
Servers -> Server Types -> WebSphere application servers.
Select the server that your application is deployed on ("server1" by default)
In the section "Server-specific Application Settings", change the Classloader policy to "Multiple"
Click "OK", then "Save to the master configuration"
You may then need to restart the server before the changes take effect.

Categories