• 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

Log4j - log4j.properties configuration for separate logs and not on root logs.

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

I do have a problem. We do have 3 application deployed on a JBoss server. All the logs are going to server.log.

Now, I would like to configure application specific logs for each application.

Example:

Application1 - Application1.log
Application2 - Application2.log
Application3 - Application3A.log (only for the packages com.myexample.action)
Application3 - Application3C.log (only for the packages com.myexample.common)

Please help me to setup the Log4j.properties.



Also, All the logs coming on Root log file also. I would like to avoid that too. Application logs should come only on application*.log. How to control it?

Apart from this 1 question:
If the log4j has been confired on log4j.properties (Inside war) and log4j.xml (JBoss one), then which configuration would be taken by log4j?
 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have recently came across the similar problems what you mentioned and I hope this should help.

As per your log4j properties file, you have added your application specific appenders to root logger, Remove your application specific appenders entry against the root logger and give a try.
There is one more property on log4j category named "additivity" which will help you in controlling whether to log an event in to specified appender only or with all appenders in the higher in the hierarchy. you can refer to log4j manual for more information.

Also for your other question on precedence for your log4j property file against jboss-log4j.xml(location - *.war/WEB-INF), It is decided whether you have added this entry in your jboss-web.xml or not.

If this is added, then Jboss will use the log4j property packaged along with the application.
 
Santhosh Kalisamy
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Ragav.

I tried "additivity" flag. It didn't work for me. Also, I have tried to remove log4j.properties and configure log4j.xml (on JBoss config). But, still no luck.

I have tried many combinations of the below code snippet.



In above code snippet, I tried with following combinations:
1. Just Category alone, Just Logger alone, both Category & Logger.
2. In ROOT, with/without BFS.

But, Still I do see the logs go to server.log files, but not BFS.log.

Could you please help me? All I want is, the application logs to go to BFS.log (only BFS.log) and all other JBoss logs to server.log (Except application logs) file.
 
Ragavendran Baskaran
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Santhosh,

What version of jboss you are using ? Adding the below entries in server/{profile}/conf/jboss-log4j.xml should be good enough.



Is this file BFS.log getting created or is it not at all getting created ?
 
Santhosh Kalisamy
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Ragav.

JBoss 5.1.0 (GA).

Yes, the BFS.log file has been created. But, the log goes to server.log (Root log file). BFS.log is always empty.

I have tried it. Still no log statements on BFS.log but in server.log.

 
Tick check! Okay, I guess that was just an itch. Oh wait! Just a tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic