• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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).
 
reply
    Bookmark Topic Watch Topic
  • New Topic