Separate Weblogic(11G) logs into the deployments level

Hi,

After weeks of struggling, here is a  solution how to separate logs of diffrent deployments independently.

By default Weblogic is overriding the application deployment’s log configurations.

In order to have independent log for each deployment you need to do the following steps:

1. place log4j.properties under ProjectRootDir/APP-INF/classes/

2. place log4j.jar under ProjectRootDir/APP-INF/lib/

3. Init your logger this way:

String fileName = "log4j.properties";
PropertyConfigurator.configure(filePath + fileName);
logger = Logger.getLogger(SBNLogger.class);
4. log4j.properties should like that:



log4j.rootCategory=debug, R

log4j.appender.R=org.apache.log4j.RollingFileAppender

the next line has different path+name in each project.

log4j.appender.R.File=D:bea11user_projectsdomainsbase_domain
autodeployMyProjectlogsMyProject.log
log4j.appender.R.MaxFileSize=8192KB

log4j.appender.R.MaxBackupIndex=100

log4j.appender.R.layout=org.apache.log4j.PatternLayout

log4j.appender.R.layout.ConversionPattern=%d{dd MMM yyyy HH:mm:ss} %p %m%n

log4j.logger.org.hibernate=info

log4j.logger.org.hibernate.SQL=debug

log4j.logger.org.hibernate.type=info

log4j.logger.org.hibernate.tool.hbm2ddl=info

log4j.logger.org.hibernate.cache=info
5. Make sure you don't have log4j.jar any where else but inside your deployment root Dir (as shown below).
And all the rest is history!
Have a good one,
Idan.

Related Articles:

(3377)

Clustering WebLogic 11g at different machines

Hi,

Recently I got a task to configure Cluster in Weblogic.

I found it as a good opportunity to learn and understand how Weblogic ‘s console works when it comes to Clustering.

So here are the steps from scratch:

Gear:

Machine 1:

– Install  Weblogic 11g(Linux ver)

– Configure Admin Console.

– Install new domain

Machine 2:

– Install  Weblogic 11g(Linux ver)

– Install same domain name and path (as in Machine 1)

(No need for Admin console setup)

 

* We managed all the servers from Machine 1 Admin console.

 

Machine 1 instructions:

1. Disable user name/password on startup – create new file boot.properties and place it  under the path:

$WL_HOME/DomainName/servers/security/boot.properties

The file will containe the following text:

username=weblogic

password=weblogic

* after first restart the the l/p will be encrypted automatically.

2. Fix slow startup – Turns out weblogic uses random number generator during startup.

in order to fix this you need to do the following change:

add export JAVA_OPTIONS="-Djava.security.egd=file:/dev/./urandom" to the /etc/bash.bashrc file.

3.Inside the Admin console:

-configure Admin server

– configure two machines (Env-> machines)

each machine has it’s own server IP

type=PLAIN

– configure Cluster (Env – > Cluster)

– configure two Managed servers (Env -> Servers) and connect each managed server to one of the machines.

4. Configure Nodemanager on Machine 1:

This is how Nodemanager.properties looks like:

path: $WL_HOME/common/nodemanager/nodemanager.properties

#Thu Aug 11 16:58:49 IDT 2011
DomainsFile=/usr/local/wls11g/wlserver_10.3/common/nodemanager/nodemanager.domains
LogLimit=0
PropertiesVersion=10.3
DomainsDirRemoteSharingEnabled=false
javaHome=/home/weblogic/Oracle/Middleware/jrockit_160_24_D1.1.2-4
AuthenticationEnabled=true
NodeManagerHome=/usr/local/wls11g/wlserver_10.3/common/nodemanager
JavaHome=/home/weblogic/Oracle/Middleware/jrockit_160_24_D1.1.2-4/jre
LogLevel=INFO
DomainsFileEnabled=true
StartScriptName=startWebLogic.sh
ListenAddress=
NativeVersionEnabled=true
ListenPort=5556
LogToStderr=true
SecureListener=false
LogCount=5
DomainRegistrationEnabled=false
StopScriptEnabled=true
QuitEnabled=false
LogAppend=true
StateCheckInterval=500
CrashRecoveryEnabled=true
StartScriptEnabled=true
LogFile=/usr/local/wls11g/wlserver_10.3/common/nodemanager/nodemanager.log
LogFormatter=weblogic.nodemanager.server.LogFormatter
ListenBacklog=50
*Also create new Dir inside $WL_HOME/common/nodemanager/security and copy into there
the file: SerializedSystemIni.dat
from $WL_HOME/user_projects/domain/bc_domain/security
5.Configure Nodemanager on Machine 2:
(do the same steps as in step 4)
6. Configure WLST tool in order to control and monitor weblogic servers in each machine.
Running the wlst:$WL_HOME/common/bin/wlst.sh
connecting to the main machine(our case - machine 1 address)
connect ('weblogic11','weblogic11','t3://MACHINE_1_IP:7001') (we should use the same IP when we run this command
from both machines)
enrolling the nodemanager with the main Domain path and the nodemanager path)
nmEnroll('$WL_HOME/user_projects/domain/bc_domain','$WL_HOME/common/nodemanager')
7. start NodeManagaer in Machine 1.
8. start NodeManager in Machine 2.
9. In the Admin Console(Machine 1) check via Machines (Env->Machine->Nodemanager) that the status is 'reachable'

10.  In the Admin console run both managed servers(Env->Servers->Control) they both need to be in status ‘running’.

Idan.
[ad]

Related Articles:

(3377)