aspose file tools*
The moose likes JBoss/WildFly and the fly likes Jboss - Axis2 - Log4j : log4j.properties file placement Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Products » JBoss/WildFly
Bookmark "Jboss - Axis2 - Log4j : log4j.properties file placement" Watch "Jboss - Axis2 - Log4j : log4j.properties file placement" New topic
Author

Jboss - Axis2 - Log4j : log4j.properties file placement

rastogi payam
Ranch Hand

Joined: May 09, 2011
Posts: 46

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





SCJP 1.6, OCPWCD 5
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10201
    
166

Placing it in .war/WEB-INF/classes should make it available in the classpath of the application.

[My Blog] [JavaRanch Journal]
rastogi payam
Ranch Hand

Joined: May 09, 2011
Posts: 46

.war/WEB-INF/classes already contain log4j.properties file which is used by the classes present in classes folder.
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10201
    
166

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

Joined: May 09, 2011
Posts: 46

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

Joined: May 14, 2008
Posts: 5836
    
    7

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.


JBoss In Action
rastogi payam
Ranch Hand

Joined: May 09, 2011
Posts: 46

Jboss 5.0.1 GA
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5836
    
    7

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

Joined: May 09, 2011
Posts: 46

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

Joined: May 09, 2011
Posts: 46

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

Joined: Jan 16, 2012
Posts: 56

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 ?
 
 
subject: Jboss - Axis2 - Log4j : log4j.properties file placement