Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Jboss - Axis2 - Log4j : log4j.properties file placement

 
rastogi payam
Ranch Hand
Posts: 47
Chrome Eclipse IDE Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I have my application (myapp.ear) installed on JBoss.It contains a war file (axiscustom.war) inside it, which in turn contains myservices.aar.
This aar file contains a class com.example.MyClass. Now I want to implement logging inside this class using Log4j.For that I need to place log4j.properties somewhere.
I have already tried but failed so far.Every time I got this message - Configuration file log4j.properties no found.Please help.

myapp.ear
.+-------------a.war
.+-------------b.war
.+-------------axiscustom.war
...................+----------------META-INF
...................+----------------WEB-INF
.........................................+-------------<some xml files>
.........................................+-------------modules
.........................................+-------------lib
.........................................+-------------conf
.........................................+-------------classes
.........................................+-------------services
...........................................................+----------------x.aar
...........................................................+----------------y.aar
...........................................................+----------------myservice.aar
.................................................................................+---------------META-INF
.................................................................................+---------------services.list
.................................................................................+---------------com
......................................................................................................+-------------example
.........................................................................................................................+-----------MyClass.class//here i want to implement Logging

Where should I put log4j.properties




 
Jaikiran Pai
Marshal
Pie
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Placing it in .war/WEB-INF/classes should make it available in the classpath of the application.
 
rastogi payam
Ranch Hand
Posts: 47
Chrome Eclipse IDE Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
.war/WEB-INF/classes already contain log4j.properties file which is used by the classes present in classes folder.
 
Jaikiran Pai
Marshal
Pie
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The *.aar (whatever that packaging is) would still have access to that .war/WEB-INF/classes since it's part of the same .war and they share the same classloader. Unless the .aar has some different classloader (I don't think it has). What exact problem are you running into?
 
rastogi payam
Ranch Hand
Posts: 47
Chrome Eclipse IDE Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When I tried to use log.debug("abc..."); statement inside MyClass.java ,it is not printing anything in logs and that too only with JBoss, with WAS those same logging statements were working fine.
 
Peter Johnson
author
Bartender
Posts: 5852
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which version of JBoss AS? On some versions the log4j.properties file in your app is ignored; instead you need to configure the jboss-log4j.xml file to log your apps messages.
 
rastogi payam
Ranch Hand
Posts: 47
Chrome Eclipse IDE Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jboss 5.0.1 GA
 
Peter Johnson
author
Bartender
Posts: 5852
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That file is ignore in 5.0.1. Jaikiran wrote up a method to use separate app logging, let me see if I can find that. Here they are. Looks like the first one is for 4.2.2, that might work for 5.0.1.

http://community.jboss.org/message/198691#198688
http://community.jboss.org/message/598966
 
rastogi payam
Ranch Hand
Posts: 47
Chrome Eclipse IDE Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Peter , I have gone through the link you proposed but I m bit confused about the placement of the log4j.properties and jboss-app.xml, since in my scenario there are three war files in a ear, so the placement of log4j.properties on the root of ear will affect the logging in rest of the .war files.Can you please explain it in reference to my scenario.
myapp.ear
.+-------------a.war
.+-------------b.war
.+-------------axiscustom.war
...................+----------------META-INF
...................+----------------WEB-INF
.........................................+-------------<some xml files>
.........................................+-------------modules
.........................................+-------------lib
.........................................+-------------conf
.........................................+-------------classes
.........................................+-------------services
...........................................................+----------------x.aar
...........................................................+----------------y.aar
...........................................................+----------------myservice.aar
.................................................................................+---------------META-INF
.................................................................................+---------------services.list
.................................................................................+---------------com
......................................................................................................+-------------example
.........................................................................................................................+-----------MyClass.class//here i want to implement Logging
 
rastogi payam
Ranch Hand
Posts: 47
Chrome Eclipse IDE Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's almost a month, since then I was searching for the solution .......
Can anyone please help me in getting the answer

Thanks
 
Sachin Pachari
Ranch Hand
Posts: 56
Eclipse IDE Netbeans IDE Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try to place both the log4j.properties and jar in the common WEB-INF of the ear, this may work,

is there any type of errors that you are getting ?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic