This week's book giveaway is in the Programmer Certification forum.
We're giving away four copies of OCP Oracle Certified Professional Java SE 11 Programmer I Study Guide: Exam 1Z0-815 and have Jeanne Boyarsky & Scott Selikoff on-line!
See this thread for details.
Win a copy of OCP Oracle Certified Professional Java SE 11 Programmer I Study Guide: Exam 1Z0-815 this week in the Programmer Certification forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Paweł Baczyński
  • Piet Souris
  • Vijitha Kumara

Issue with JBoss logging for different jboss instances running on same machine

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We have two JBoss instances running at the same time
(For ex:
App1.war running under %JBOSS_HOME%/server/JBoss_Instance1 and
App2.war running under %JBOSS_HOME%/server/JBoss_Instance2

on the SAME machine)

Both these apps have their own LoggerClass to access Log4j instance. (We have this class in the workspace and at ANT-Build time this class goes into both the Apps' war). Structure of Class attached at the end.

Both Apps have their own ServletContextListeners which initializes their respective Loggerclasses at respective JBoss start up.

The problem is:
Both Apps creates/initializes their app.log files but only one of them succeeds in logging while other doesn't.

The way we access in our code where we need to log is -

SomeLogger logger = SomeLogger.getLogger();
/*some logic*/
logger.logInfo("ClassName.API","Log Message");

Workaround:
We created LoggerClass1 for App1 and LoggerClass2 for App2 (except different name for class, they both are identical)- Things worked awesome

Could there be a problem at the JBoss-Log4j configuration, that we are missing? Or does logging of apps in JBoss is handled at Container level rather than App level?

Any pointer or directions would be of great help.



 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By default Jboss uses "Unified Class loaders",meaning all the java structural elements will get loaded into one class loader causing this conflict. All you need do is to define a Class loader Isolation, please refer to Jboss wiki for details.

http://community.jboss.org/wiki/ClassLoadingConfiguration


Specifying Isolation:

For .ear files, in your jboss-app.xml, add the following descriptor fragment construct to enable scoped class loading:
<jboss-app>
<loader-repository>
com.example:archive=unique-archive-name
</loader-repository>
</jboss-app>

For .war files, in your jboss-web.xml, the following template applies:
<jboss-web>
<class-loading>
<loader-repository>com.example:archive=unique-archive-name</loader-repository>
</class-loading>
</jboss-web>

 
author
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Panayappan and Senthil, welcome to Java Ranch!

@Panayappan, which version of JBoss AS? Logging was radically changed in each of the last several releases, so not knowing which version you are using makes it difficult to provide advice.
 
Senthil Balakrishna
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just out of curiosity, why not use JBoss logging functionality rather than handling it at application level ? That way you can control dynamically the logging levels thro' JBoss console.
 
Panayappan Periyakaruppan
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Senthil and Peter.

@Peter - we are using jboss-5.1.0.GA

@Senthil - thanks for the reference link. It is a requirement that we need individual log file and hence individual log4j properties. For different apps, we might adjust log levels as and when required. That is, changing log level for one app should not affect log levels of other applications.

We will experiment the suggestion as in the reference link above and given an update.


Here is the log4j properties that we use.



log4j.rootCategory=INFO, R

#### First appender writes to console
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout

# Pattern to output the caller's file name and line number.
log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} [%p] %c{1} %m%n

#### Second appender writes to a file
log4j.appender.R=org.apache.log4j.RollingFileAppender
log4j.appender.R.File=${PROJ_HOME}/runtime/log/app1.log

# Control the maximum log file size
log4j.appender.R.MaxFileSize=100KB
# Archive log files (one backup file here)
log4j.appender.R.MaxBackupIndex=1

log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %c{1} [%p] %m%n
 
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Panayappan Periyakaruppan wrote:We have two JBoss instances running at the same time
(For ex:
App1.war running under %JBOSS_HOME%/server/JBoss_Instance1 and
App2.war running under %JBOSS_HOME%/server/JBoss_Instance2

on the SAME machine)


You mean 2 separate applications each on a separate JVM? In that case I don't see how the 2 instances are interfering with each other during logging (unless you share the same file to which the logs get written).
 
Roses are red, violets are blue. Some poems rhyme and some don't. And some poems are a tiny ad.
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!