• 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
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

How to have my own log4j.xml file in Jboss

 
Ranch Hand
Posts: 342
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey,

I work with Jboss 4.2.
My application deploy as an ear file.

where should i put my log4j file in the application ear withot having a conflicts with Jboss?

thank you
 
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by avihai marchiano:

I work with Jboss 4.2.
My application deploy as an ear file.

where should i put my log4j file in the application ear withot having a conflicts with Jboss?



This is what I think should work , but there might be other better ways of doing the same.

you can have a config directory packed within the EAR and add an entry named Class-Path in the menifest.mf that you are planning to ship with this EAR and that should include this config directory.Now while packing this EAR put the log4j.xml in that config folder.
[ September 18, 2007: Message edited by: Rahul Bhattacharjee ]
 
Ranch Hand
Posts: 1855
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
jboss-4.2.1.GA\server\default\conf
 
Rahul Bhattacharjee
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Darya Akbari:
jboss-4.2.1.GA\server\default\conf


I am not aware of the JBosses clasloading structure but it seems to me that putting the config file there would make it available to all the applications deployed in the server , not to one particular ear.
 
Darya Akbari
Ranch Hand
Posts: 1855
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't see why to put log4j.xml or jboss-log4j.xml (latest JBoss versions) into an EAR.

You normally leave it there where JBoss already put it for you. Here is where you control the output of JBoss' server.log file.

Regards,
Darya
[ September 22, 2007: Message edited by: Darya Akbari ]
 
Rahul Bhattacharjee
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Darya Akbari:
I don't see why to put log4j.xml or jboss-log4j.xml (latest JBoss versions) into an EAR.



Because its specific to that application , not to all the applications hosted in that application server.
 
avihai marchiano
Ranch Hand
Posts: 342
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Exctly.

Also jboss-log4j is fo jboss logs.
My aplication runs also without jboss. unit tests and etc and i dont want to have duplicate log4j fils.
 
Rahul Bhattacharjee
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by avihai marchiano:
Exctly.

Also jboss-log4j is fo jboss logs.
My aplication runs also without jboss. unit tests and etc and i dont want to have duplicate log4j fils.



have you tried what I have mentioned ?
 
avihai marchiano
Ranch Hand
Posts: 342
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Not yet.

I understand that they solve the problem in JBoss 4.2

I hope to try this in the next few days.

How do i add it to the manifest?
(i buid with mavn2).

do you mean to add it to the manifest of each jar?

Thank you
 
Rahul Bhattacharjee
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by avihai marchiano:
Not yet.

I understand that they solve the problem in JBoss 4.2

I hope to try this in the next few days.

How do i add it to the manifest?
(i buid with mavn2).

do you mean to add it to the manifest of each jar?

Thank you



Your EAR would have META-INF folder and that will have the menifest.mf file.
 
Darya Akbari
Ranch Hand
Posts: 1855
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I have two quotes from you avihai:

Originally posted by avihai marchiano:
My application deploy as an ear file.



and

Originally posted by avihai marchiano:
My aplication runs also without jboss



Which one is true now, maybe both of them are true . Is it now an EAR you deploy or not? If it is an EAR how can it run w/o an J2EE application server in this case JBoss? If it is not an EAR and more kind of standalone application or a client JAR then this is a different story. EAR is for JBoss , JAR is for a standalone or client application.

In case of an EAR, you are embedded in JBoss' infrastructure which includes Logging from that moment on you deployed it. In your code the only thing you need to do is to get the JBoss Logger with getLogger(yourClass). In case of a standalone or client application you need to write your own Logger first and put it in your JAR or classpath but not into your EAR.

So you must distinguish where you log client, server or both. I don't think that you can mix server and client, because JBoss has its own server.log where only server stuff including your EAR are logged. For all client stuff you create and use your own log file and Logger. While the server log file reside on the server you keep your client log file on client side.

Regards,
Darya
 
Rahul Bhattacharjee
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by avihai marchiano:
My aplication runs also without jboss


I guess by this he means that his application runs on some other application server too.
But its just my guess.
 
avihai marchiano
Ranch Hand
Posts: 342
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Both true. I will explain.

My application deploy as a ear,

But i can run some of the project that deploy at the ear in stand alone mode (for unit testing).

no, i dont mix the client and server.

lets say i have common,serverInfrustrcutre (depend on common), server(depends on both). i can run unit testing against each project.
In the loging i dont want to log the client (this is another log4j file). i want to have the log definitions like i run it onb the server.

I thing the application need to have its own logging seperate from jboss loging definitions.
 
Darya Akbari
Ranch Hand
Posts: 1855
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Rahul Bhattacharjee:
I guess by this he means that his application runs on some other application server too.



I think these app servers all work quite the same. Let it be xyz-log4j.xml instead of jboss-log4j.xml (JBoss 4.2+) in case of another app server.

Regards,
Darya
 
Darya Akbari
Ranch Hand
Posts: 1855
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by avihai marchiano:
My application deploy as a ear,

But i can run some of the project that deploy at the ear in stand alone mode (for unit testing).



Can you explain it in more detail. How does your standalone mode and how does your unit testing look like?

Regards,
Darya
 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi guys,

I am working around the same problem of separating the log4j properties files in jboss. My stuff is working fine when I add the appenders to jboss conf/log4j.xml and now I am trying out the option that Rahul suggested. I am using maven for building the project and I have put the log4j.xml under src/main/resources/conf folder and the packaged jar has the correct path as conf/log4j.xml. Now how do I add this file to the Class-Path in manifest.mf. my plugin settings in pom.xml are as follows.

<plugin>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
</manifest>
</archive>
</configuration>
</plugin>

It is adding all the dependency jars to classpath, but not log4j.xml. Any ideas how to get this thing to work?

Regards,
Vidya
 
Politics n. Poly "many" + ticks "blood sucking insects". Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic