how can i set a java_option - in my case java.util.logging.manager - per web application in weblogic ?
I cant set in globally, since weblogic logging also uses this same log manager.
I only need the logs from the web applications - to point to a different log manager.
thanks in advance. :)
You can set it in log4j for each application and have it written to different log file. You can specify the file path in log4j.appender.file.File variable
Related
We have Spring java-based web applications which use log4j2.xml for logging messages to files, etc.
We now need to update our log4j2.xml configs in order to be able to do a ${a.b.c} web lookup inside them so that we can use a JVM custom property value as part of the log file's name which the loggers log messages to. "a.b.c" is a JVM custom property name in IBM WAS9.0. However, when we deploy the apps, the log4j2 configurations fail to recognize any web lookup related stuff. The file created to log messages to is simply created with the name ${a.b.c} and no messages are actually logged in them. I have log4j-api, log4j-core, log4j-web in pom.xml.
I have read various docs online related to log4j2 web lookups when running in 3.0 servlets but I still can't see what the problem might be in our configurations. And I don't know what to look for in the log4j's trace logs in order to see what it is that we are missing.
Our Stack:
Spring 4.3.x
Solaris
Java 8
IBM WAS9.0
log4j-2.17.0 (log4j-api, log4j-core, log4j-web all in classpath)
I get this issue resolved by referencing the IBM WAS JVM custom property by ${sys:condir} in the log4j2.xml file.
We have an application running on websphere 8.5 and we'd like to pull the value of a custom property created using the following method in websphere admin console:
Servers->Application Servers->server1->Process Definition->Java Virtual Machine->Custom Properties -> (new)
In the code, we are trying System.getProperty("property_name") to retrieve the property but to no avail as the result is coming out null. We've seen examples online but they are only pulling websphere variables.
Has anyone encountered and fixed this issue before ? We are using this code in static block (though we don't think that it'll make a difference).
Thanks,
JVM "custom properties" in the admin console are just system properties used to start the JVM, so System.getProperty should work, but you must restart the JVM for the system properties to be used.
I have a web application, which uses log4j and slf4j as facade for logging. Logging is configured not from log4j.properties file, but from Java code.
Application is running on three different machines using Websphere Application Server.
Issue is that on two instances logging works as expected. But on the third one nothing is written in my logfile. Output goes to SystemErr.log instead (there are messages of ERROR and INFO levels).
Initially I thought that something is with Websphere server configuration, but later I found this link http://www.webagesolutions.com/knowledgebase/waskb/waskb004/ which says that such situation can be when log4j.properties can not be read.
But I am not using property file for this. And configuration form Java works OK on other two instances.
Any ideas what can be the issue?
Thank you in advance!
Please make sure that no alternative slf4j binding (such as simple) exists on the CLASSPATH.
I'm trying to use log4j to handle the logs for a web-service which is running under Glassfish 3. Most of the guides I've seen using log4j with Glassfish want me to mess around with Glassfish global settings, which I want to avoid as there will be more than one application deployed per instance of Glassfish.
Is there any way for me to have Glassfish execute a piece of code when my web service is deployed which will allow me to call DOMConfigurator and set up log4j using my XML file?
Thanks for any help!
EDIT: The answer is to place the log4j.xml file in WEB-INF/classes. In our case, it looks as if log4j remains un-configured, but logging does still actually work as expected.
Yes. All you need to do is deploy the log4j configuration with the component you're deploying; log4j will use the locally-scoped configuration as long as it's not being referenced in a parent classloader.
Glassfish' global settings won't factor in at all in that case.
We have a WAR file that is deployed however we want to change the database settings. How do I get about doing that? I opened the WAR file in an IDE and there are like 2-3 places that have the database settings. What is the proper way of changing it?
Thank You
The proper way is to use a datasource at the application level and to administer it at the application server level. Check the MySQL DBCP Example in the Tomcat documentation.
The tomcat instance should be set up to provide a datasource through JNDI.