• 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

Using Log4j with Jboss

 
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So I thought I would be studious and add correct logging to my jboss project. :|

I'm having problems using Log4j (logging.apache.org/log4j) with Jboss. The things I know are:

that jboss uses log4j itself
that you must rename server/conf/log4j.xml to jboss-log4j.xml if you want your war's to have their own log4j.xml files to define their own logging.

But my problem is that I just want to define a limit on certain packages in my project, and append that to the main server.log.

so adding a log4j.xml file to my class root with just
<category name="com.company.packageparent">
<priority value="INFO"/>
</category>

<category name="com.company.packageparent.packagechild">
<priority value="DEBUG"/>
</category>

i don't think is right, and jboss complains about not being able to to parse the log xml.

Adding those categories to the actual jboss xml file didn't do anything either.

Any ideas would be most appreciated!
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


i don't think is right, and jboss complains about not being able to to parse the log xml.


What is the error you are seeing?
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How will it know which appender to use? In order for that category to log stuff if needs to have a reference to at least one appender.

Mark
 
Johnny Gara
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry but I've changed things up quite a bit. I was looking at the jboss docs for this and really, what I really want is to simply set the log level in the jboss log4j.xml file.

Whic if you were looking at the docs is as simple as :
http://docs.jboss.org/process-guide/en/html/logging.html

adding a new


type of category.

But when I do that, none of my logs show up again except fatal ones.

all I've added was the category to the log4j.xml file, and called my logger using:



....I guess I could just change all my logs to fatal
 
Johnny Gara
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Mark Spritzler:
How will it know which appender to use? In order for that category to log stuff if needs to have a reference to at least one appender.

Mark



I was under the impression that a category would simply default to the root appender (if there is even such a thing?)? Since most of the categories defaulted in the xml file don't have an appender...

I did though add a specific appender to a separate log file, but the log file hasn't logged anything yet.
 
Johnny Gara
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok, I've somewhat figured out a lot of my problems.

In my ant build script, I download dependencies automatically, but the problem is that one of the dep actually contained log4j.jar as part of it's library, which of course added to my war lib, which of course made jboss

So tried to simply delete the log4j jar from my war lib, and I got logs!

Lesson of the day: JBoss doesn't like it when you have a log4j jar within your lib!

thanks to everyone that posted
 
Mark Spritzler
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by John lee:


I was under the impression that a category would simply default to the root appender (if there is even such a thing?)? Since most of the categories defaulted in the xml file don't have an appender...

I did though add a specific appender to a separate log file, but the log file hasn't logged anything yet.



Yes you are right it defaults to the root appender. I thought you were looking for you apps logs to be going to a different location. Sorry.

Mark
 
reply
    Bookmark Topic Watch Topic
  • New Topic