rayman
rayman

Reputation: 21616

Configure log files for specific application in Weblogic

I am using Weblogic 11g, EJB3.0.

I am struggling for weeks with this problem.

I have several deployments(Stateless beans).

each one has it's own log4j jar (log4j-1.2.15.jar) and each one has it's own log4j.properties.

problem is: when the I write to log(debug/error/info etc.) all logs from all deployments are written to the same log file.

this is annoying since I want each deployment to write to it's own and only log file (which configured in it's log4j.properties)

this is my log4j.properties file:

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\:\bea11\user_projects\domains\base_domain\autodeploy\MyProject\logs\MyProject.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

my project is divided to three dependencies in Myeclipse:

ProjectName

ProjectNameEJB

ProjectnameWeb

and I have installed in in Weblogic as Exploded Archive

the jar is located under this dir path: ProjectName/ear/app-inf/lib/log4j-1.2.15.jar

and log4j.properties located under the root dir: ProjectName/log4j.properties

Thanks, ray

Upvotes: 0

Views: 9040

Answers (2)

ag112
ag112

Reputation: 5697

@rayman: you need to check first what is classloading policy of your project in weblogic console...if they are sharing same classloader for Logger class (as class is unique per classloader), then it is going to use same instance of logger using same configuration... ...you can also print file location used by logger by calling below in each of your application at some point:-

((org.apache.log4j.RollingFileAppender)org.apache.log4j.Logger.getRootLogger().getAppender("R") ).getFile()

Upvotes: 0

rayman
rayman

Reputation: 21616

must locate the properties.xml under app-inf/classes

and the the log4j.jar under app-inf/lib

and make sure you dont have the log4j.jar under the server/lib dir.

Upvotes: 1

Related Questions