I have multiple ears,For certain Ears I want log4j details to be picked from Weblogic level and for certain application I have application level log4j.xml bundled with ear.
Copied wllog4j.jar and Log4j-x.x.x.jar to Server classpath
Added the following JAVA_OPTION in
startWebLogic.sh -Dlog4j.Configuration=Mylog4j.xml
and add the "Mylog4j.xml" in the Server Classpath
as :
SAVE_JAVA_OPTIONS="${JAVA_OPTIONS}" -Dlog4j.Configuration=Mylog4j.xml
SAVE_CLASSPATH="${CLASSPATH}:/apps/myfiles/MyLog4j.xml"
For application which have application level log4j.xml ,I have mentioned prefer-application-packages in weblogic-application.xml
<prefer-application-packages>
<package-name>org.apache.log4j.*</package-name>
</prefer-application-packages>
But the logs are not getting generated for those application which has there log4j.xml
Also,Just for info : Applications are using slf4j/commons-logging and log4j
Please suggest !!!
The issue was related to classloading : Below line in weblogic-applicaton.xml does the trick.
<prefer-application-packages>
<package-name>org.apache.log4j.*</package-name>
<package-name>org.apache.*</package-name>
<package-name>org.slf4j.*</package-name>
</prefer-application-packages>
Follow below steps
1) copy log4j.jar and wllog4j.jar in server lib folder
2) copy your log4j.xml in server domain folder
3) change setDomaninEnv.xml to point to your log4j.xml file ex: LOG4J_CONFIG_FILE="${DOMAIN_HOME}/log4j.xml"
Related
I want to configure my Liferay portlet project with own log4j configurations.I have followed following article and it is working fine for me.
https://web.liferay.com/web/brett.swaim/blog/-/blogs/using-log4j-to-ensure-each-portlet-has-it-s-own-log-file
Now I need to use log4j.properties file instated of log4j.xml file.So I have removed log4j.xml and put a sample log4j.properties file.After putting log4j.properties file, portlet project does not identify the log4j configurations.
My Liferay version is Liferay 6.2 CE GA5.
Sample log4j.properties file is,
log4j.rootLogger=ERROR,console
#Console Appender
log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern=[%5p] [%t %d{hh:mm:ss}] (%F:%M:%L) %m%n
#Custom assignments
log4j.logger.controller=DEBUG,console
log4j.logger.service=DEBUG,console
log4j.logger.dao=DEBUG,console
#Disable additivity
log4j.additivity.controller=false
log4j.additivity.service=false
log4j.additivity.dao=false
Can anybody help me resolve this issue?
I have finally found the fix.Need to define the log4j properties file path in the web.xml.I have placed my log4j.properties file in the WEB-INF folder.
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>/WEB-INF/log4j.properties</param-value>
</context-param>
In my project (myProject) I use an external jar (external.jar). Both of them make logging with log4j.jar . With the help of log4j.properties file (located in myProject) I can configure logging from myProject. How can I configurate log levels of logging from the the external.jar without changing that jar file ?
Simpy adding package from external.jar ( let say org.external) in property file
log4j.logger.org.external=ERROR does not make any difference.
Here I have found the salution.
I'm trying to get slf4j 1.7.7 to use log4j 2.0.2 as its implementation. I think I have all the necessary JARs in my WAR and the log4j.xml just gets dropped into the classes directory, but when my webapp starts up, it can't locate the log4j.xml. When I crack open the WAR, I can see it in the WEB-INF/classes, so it should be on the classpath. What am I missing?
meta-inf/manifest.mf
index.html
...
WEB-INF/web.xml
WEB-INF/classes/log4j.xml
...
WEB-INF/lib/log4j-api-2.0.2.jar
...
WEB-INF/lib/slf4j-api-1.7.7.jar
...
WEB-INF/lib/log4j-core-2.0.2.jar
WEB-INF/lib/log4j-slf4j-impl-2.0.2.jar
...
Jetty has this in its stderrout.log file, recording its disappointment...
ERROR StatusLogger No log4j2 configuration file found. Using default configuration: logging only errors to the console.
Well that is subtle. log4j-core-2.0.2 isn't looking for log4j.xml, its looking for log4j2.xml. The FAQ page http://logging.apache.org/log4j/2.x/faq.html has, in bold, "By default, Log4j looks for a configuration file named log4j2.xml (not log4j.xml) in the classpath." Renaming my file to log4j2.xml gets it found. Now I've got to make it correct.
2014-10-24 10:34:53,542 ERROR Unknown object "property" of type org.apache.logging.log4j.core.config.Property is ignored.
2014-10-24 10:34:53,545 ERROR Unknown object "logger" of type org.apache.logging.log4j.core.config.LoggerConfig is ignored.
2014-10-24 10:34:53,546 ERROR Unknown object "root" of type org.apache.logging.log4j.core.config.LoggerConfig is ignored.
I tried the following steps:
At first I installed the feature "WSO2 Carbon - J2EE Runtime Environment" in the AS. Then I created a new dynamic web project in Eclipse with Servlet Module 2.5 and a configuration for JSF 1.2 using Myfaces 1.2.9 and a JSF-HTML-Template. After I had written "hello" in the view, I tested it with "run on server" in Eclipse and it runs. Then I created a WAR-File and deployed it in the AS with pasting the file in "asroot/repository/deployment/server/webapps".
Then I tried the page and it throws this error:
"/NewFile.jsp(2,57) PWC6188: The absolute uri: http://java.sun.com/jsf/core cannot be resolved in either web.xml or the jar files deployed with this application
Caused by:
org.apache.jasper.JasperException - /NewFile.jsp(2,57) PWC6188: The absolute uri: http://java.sun.com/jsf/core cannot be resolved in either web.xml or the jar files deployed with this application"
I tried it also on a local Tomcat-Server with the same result like in Eclipse.
The libs in the WAR are:
javax.servlet.jsp.jstl-1.2.1.jar
javax.servlet.jsp.jstl-api-1.2.1.jar
commons-beanutils-1.7.0.jar
commons-codec-1.3.jar
commons-collections-3.2.jar
commons-digester-1.8.jar
commons-discovery-0.4.jar
commons-logging-1.1.1.jar
myfaces-api-1.2.9.jar
myfaces-impl-1.2.9.jar
This could be a classloading issue. Please put webapp-classloading.xml file in META-INF directory of your web application with following configurations
<?xml version="1.0" encoding="ISO-8859-1"?>
<Classloading xmlns="http://wso2.org/projects/as/classloading">
<Environments>Tomcat</Environments>
</Classloading>
Refer http://docs.wso2.org/display/AS520/Webapp+ClassLoading
When I launch a Grid hub using Ant, the logging is all by default on the console. I would like to know if there is a way wherein I can alter the build.xml file of Selenium Grid and include a log4j logger into it. I understand that I can specify a log file to Ant itself using the -logfile option. But this would cause the log file to be overwritten everytime the grid is launched. I want to ensure that the log files are automatically renamed after a threshold is reached for better maintenance. Any help and if possible some examples on how to do it would be greatly appreciated (I am new to using log4j which is why I am asking for some sample for this specific need).
You need to specify the location of the Log4j archive as well as its configuration file when starting up Selenium. In the following example, I've updated the classpath to load the log4j.hub.properties configuration file located in the /etc/selenium directory and the log4j.jar located in the /usr/lib/selenium directory. I've also setup some additional log files:
java -classpath /etc/selenium:/usr/lib/selenium/log4j.jar:/usr/lib/selenium/selenium-server-standalone.jar -Dlog4j.configuration=log4j.hub.properties org.openqa.grid.selenium.GridLauncher -role hub -log /var/log/selenium/hub.debug.log > /var/log/selenium/hub.output.log 2> /var/log/selenium/hub.error.log &
Then you can have something like the following to achieve what you are looking for:
log4j.rootLogger=ALL, file
log4j.appender.file=org.apache.log4j.FileAppender
log4j.appender.file.File=/var/log/selenium/hub.log
log4j.appender.file.Append=true
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss,SSS} <%p> <%t> %m%n
You might want to look at this page for more information about how Selenium logging is working.