Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Weblogic 8.x and log4j

Posted on 2004-10-10
6
Medium Priority
?
1,781 Views
Last Modified: 2013-12-10
Dear Experts

I am writting a simple application using weblogic workshop and I want to be able to write/log to file using apache's log4j


Here is what I want to do:
1. Configue weblogic (8.x) and my app to write to a specified log file in my log4j.properties file
2. write logs (info,debug,warning) to the file on the app server from the application jsp, ejbs, and java (javabean) programs
3. provide a simple link to view the log file in my app

I have used log4j extensively in the past on standalone java programs, it just gets a little tricky in the app server environment..

Please provide simple and concise sample code and instructions..

Thanks


0
Comment
Question by:bmukoro
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 4

Accepted Solution

by:
illusionz70 earned 672 total points
ID: 12274102
its used just the same way .... copy the libraries to your lib folder of app server.
set the logger , and log the same thougout your application.

for eg ,

log4j.rootLogger=FATAL, dest1
log4j.logger.sampleLogging=DEBUG, samplelog
 #samplelog will be the name of file where logs are written into
log4j.additivity.stpLogging=false

log4j.appender.dest1=org.apache.log4j.ConsoleAppender
log4j.appender.dest1.layout=org.apache.log4j.PatternLayout
log4j.appender.dest1.layout.ConversionPattern=%-5p:%l: %m%n
log4j.appender.dest1.ImmediateFlush=true

log4j.appender.samplelog=org.apache.log4j.RollingFileAppender
log4j.appender.samplelog.File="path wher file is store"
log4j.appender.samplelog.MaxFileSize=5000KB
log4j.appender.samplelog.MaxBackupIndex=5
log4j.appender.samplelog.layout=org.apache.log4j.PatternLayout
log4j.appender.samplelog.layout.ConversionPattern=%l:%d: %m%n

and
in your code
Logger log = Logger.getLogger("sampleLogging");


and then log.debug everywhere.

cheers,
0
 
LVL 3

Assisted Solution

by:joefm1218
joefm1218 earned 664 total points
ID: 12319949
In order to give me the ability to change my properties file without re-deploying the app, I leave my log4j.properties file outside the EAR file. I then add the properties directory to my jvm's classpath when starting the application server.

I place the necessary log4j jar files within the root directory of my EAR file. For any sub archives (ie. WAR files, EJB jar files, etc.), I create a entry in each of the Manifest files to point to these log4j jar files.

Example of war manifest:

Manifest-Version: 1.0
Created-By: Me
Class-Path: <some jar's...>.jar commons-logging.jar log4j-1.2.8.jar

0
 
LVL 23

Assisted Solution

by:rama_krishna580
rama_krishna580 earned 664 total points
ID: 12430629
Hi,

1. Configue your log4j.xml file..like below..

<?xml version= "1.0 " encoding= "UTF-8 " ? > 
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd " >

<log4j:configuration xmlns:log4j= ' http://jakarta.apache.org/log4j/ ' > 

<appender name= "ROOT " class= "org.apache.log4j.ConsoleAppender " >
<param name= "File " value= "C:/Log4jLogs/root.log "/ > 
<layout class = "org.apache.log4j.PatternLayout " >
<param name= "ConversionPattern " value= "[%t] %-5p %c - %m%n "/ > 
</layout > 
</appender > 

<root > 
<level value= "ON "/ > 
<appender-ref ref= "ROOT " / > 
</root > 

<appender name= "NETMAINT " class= "org.apache.log4j.ConsoleAppender " >
<param name= "File " value= "C:/Log4jLogs/netmaint.log "/ > 
<layout class = "org.apache.log4j.PatternLayout " >
<param name= "ConversionPattern " value= "[%t] %-5p %c - %m%n "/ > 
</layout > 
</appender > 

<logger name= "NetMaint " >
<level value= "DEBUG "/ > 
</logger > 

<logger name= "NetMaint " >
<appender-ref ref= "NETMAINT " / > 
</logger > 

</log4j:configuration > 


2. Writing log4j files...
http://www.qos.ch/logging/sc.html

3. http://www.onjava.com/pub/a/onjava/2003/04/02/log4j_ejb.html

R.K

0
 

Author Comment

by:bmukoro
ID: 12613175
I decided to use the weblogic console logger

Thanks for you comments/suggestions
0

Featured Post

Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Configure Web Service (server application) I. Configure security for Web Services methods First, we need to protect Session bean which implements the service: 1. Open EJB deployment descriptor (ejb-jar.xml) in the EJB project that contains you…
This exercise is about for the following scenario: Dmgr and One node with 2 application server. Each application server contains it owns application. Application server name as follows server1 contains app1 server2 contains app1 Prereq…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question