Where to place log4j.xml

It finds the log4j.xml using the CLASSPATH. If log4j doesn’t find any config file, it will send an error to the console. If you don’t see any such error then it is likely that it is finding a config file which may not be the one you are editing. There is a command-line option to … Read more

How do you get log4j to roll files based on date and size?

Looks like you want a mix of the http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/DailyRollingFileAppender.html and the http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/RollingFileAppender.html. You’ll have to code by yourself. The good news is: you’ll just have “merge” those classes functionality, no “low level” new code required.

How to log Apache CXF Soap Request and Soap Response using Log4j?

You need to create a file named org.apache.cxf.Logger (that is: org.apache.cxf file with Logger extension) under /META-INF/cxf/ with the following contents: org.apache.cxf.common.logging.Log4jLogger Reference: Using Log4j Instead of java.util.logging. Also if you replace standard: <cxf:bus> <cxf:features> <cxf:logging/> </cxf:features> </cxf:bus> with much more verbose: <bean id=”abstractLoggingInterceptor” abstract=”true”> <property name=”prettyLogging” value=”true”/> </bean> <bean id=”loggingInInterceptor” class=”org.apache.cxf.interceptor.LoggingInInterceptor” parent=”abstractLoggingInterceptor”/> <bean id=”loggingOutInterceptor” … Read more

How to initialize log4j properly?

Log4j by default looks for a file called log4j.properties or log4j.xml on the classpath. You can control which file it uses to initialize itself by setting system properties as described here (Look for the “Default Initialization Procedure” section). For example: java -Dlog4j.configuration=customName …. Will cause log4j to look for a file called customName on the … Read more